diff --git a/changelogs/unreleased/issue-67127.yml b/changelogs/unreleased/issue-67127.yml new file mode 100644 index 0000000000000000000000000000000000000000..70848dc6ff9e0e6324b35cc2864e29d133d533c3 --- /dev/null +++ b/changelogs/unreleased/issue-67127.yml @@ -0,0 +1,5 @@ +--- +title: Expose 'protected' field for Tag API endpoint. +merge_request: 32790 +author: Andrea Leone +type: added diff --git a/doc/api/tags.md b/doc/api/tags.md index 1d874fea1f81be8c6d0f036e608dc45bab4a4125..88f63d6b34b28823a3a16855071ba1d5a2500a41 100644 --- a/doc/api/tags.md +++ b/doc/api/tags.md @@ -46,7 +46,8 @@ Parameters: }, "name": "v1.0.0", "target": "2695effb5807a22ff3d138d593fd856244e155e7", - "message": null + "message": null, + "protected": true } ] ``` @@ -94,7 +95,8 @@ Example Response: "committer_email": "contact@arthurverschaeve.be", "committed_date": "2015-02-01T21:56:31.000+01:00" }, - "release": null + "release": null, + "protected": false } ``` @@ -138,7 +140,8 @@ Parameters: }, "name": "v1.0.0", "target": "2695effb5807a22ff3d138d593fd856244e155e7", - "message": null + "message": null, + "protected": false } ``` diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c9b3483acafe6041891bb264731e61e443c2bb52..312c8d5b548d13170676c4ff5d91a42456bbb1c5 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1312,6 +1312,10 @@ module API options[:project].releases.find_by(tag: repo_tag.name) end # rubocop: enable CodeReuse/ActiveRecord + + expose :protected do |repo_tag, options| + ::ProtectedTag.protected?(options[:project], repo_tag.name) + end end class Runner < Grape::Entity diff --git a/spec/fixtures/api/schemas/public_api/v4/tag.json b/spec/fixtures/api/schemas/public_api/v4/tag.json index 5713ea1f5262c2a6440a1c09f097970cc2acb5ad..bb0190955f07f9ff82f45014d4f01d1e2ae4c095 100644 --- a/spec/fixtures/api/schemas/public_api/v4/tag.json +++ b/spec/fixtures/api/schemas/public_api/v4/tag.json @@ -16,7 +16,8 @@ { "type": "null" }, { "$ref": "release/tag_release.json" } ] - } + }, + "protected": { "type": "boolean" } }, "additionalProperties": false }