BigW Consortium Gitlab

Commit 3a4086e2 by Andrew Beresford

Expose the target commit ID through the tag API

This is useful for annotated tags, where the deferenced target is not the same as the tag object. At the moment there is no way to differentiate the two through the tag API. This change adds a "target" property and leaves the existing "commit" property alone so that existing behaviour is not altered.
parent 86ca1a77
---
title: Expose the target commit ID through the tag API
merge_request:
author:
type: added
...@@ -42,6 +42,7 @@ Parameters: ...@@ -42,6 +42,7 @@ Parameters:
"description": "Amazing release. Wow" "description": "Amazing release. Wow"
}, },
"name": "v1.0.0", "name": "v1.0.0",
"target": "2695effb5807a22ff3d138d593fd856244e155e7",
"message": null "message": null
} }
] ]
...@@ -73,6 +74,7 @@ Example Response: ...@@ -73,6 +74,7 @@ Example Response:
{ {
"name": "v5.0.0", "name": "v5.0.0",
"message": null, "message": null,
"target": "60a8ff033665e1207714d6670fcd7b65304ec02f",
"commit": { "commit": {
"id": "60a8ff033665e1207714d6670fcd7b65304ec02f", "id": "60a8ff033665e1207714d6670fcd7b65304ec02f",
"short_id": "60a8ff03", "short_id": "60a8ff03",
...@@ -132,12 +134,16 @@ Parameters: ...@@ -132,12 +134,16 @@ Parameters:
"description": "Amazing release. Wow" "description": "Amazing release. Wow"
}, },
"name": "v1.0.0", "name": "v1.0.0",
"target: "2695effb5807a22ff3d138d593fd856244e155e7",
"message": null "message": null
} }
``` ```
The message will be `null` when creating a lightweight tag otherwise The message will be `null` when creating a lightweight tag otherwise
it will contain the annotation. it will contain the annotation.
The target will contain the tag objects ID when creating annotated tags,
otherwise it will contain the commit ID when creating lightweight tags.
In case of an error, In case of an error,
status code `405` with an explaining error message is returned. status code `405` with an explaining error message is returned.
......
...@@ -928,7 +928,7 @@ module API ...@@ -928,7 +928,7 @@ module API
end end
class Tag < Grape::Entity class Tag < Grape::Entity
expose :name, :message expose :name, :message, :target
expose :commit, using: Entities::Commit do |repo_tag, options| expose :commit, using: Entities::Commit do |repo_tag, options|
options[:project].repository.commit(repo_tag.dereferenced_target) options[:project].repository.commit(repo_tag.dereferenced_target)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"name": { "type": "string" }, "name": { "type": "string" },
"message": { "type": ["string", "null"] }, "message": { "type": ["string", "null"] },
"commit": { "$ref": "commit/basic.json" }, "commit": { "$ref": "commit/basic.json" },
"target": { "type": "string" },
"release": { "release": {
"oneOf": [ "oneOf": [
{ "type": "null" }, { "type": "null" },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment