summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/unreleased/issue-67127.yml5
-rw-r--r--doc/api/tags.md9
-rw-r--r--lib/api/entities.rb4
-rw-r--r--spec/fixtures/api/schemas/public_api/v4/tag.json3
4 files changed, 17 insertions, 4 deletions
diff --git a/changelogs/unreleased/issue-67127.yml b/changelogs/unreleased/issue-67127.yml
new file mode 100644
index 00000000000..70848dc6ff9
--- /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 1d874fea1f8..88f63d6b34b 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 c9b3483acaf..312c8d5b548 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 5713ea1f526..bb0190955f0 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
}