summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2016-04-06 13:24:56 +0000
committerJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2016-04-06 13:24:56 +0000
commitc49f9c61742a078e8b9aacbfdba0dd936a89ea6a (patch)
tree789766ad1b383310fc74b055e6869f1f1698f7bf
parentf76bfed9fc3e52c7b3b731dbb311b6b394d9af62 (diff)
parent7f287c9136d5d1cdda8df170c6e772ca82aad1e9 (diff)
downloadgitlab-ce-c49f9c61742a078e8b9aacbfdba0dd936a89ea6a.tar.gz
Merge branch 'api-retrieve-tag' into 'master'
API: Ability to retrieve a single tag * Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/14330 /cc @dblessing See merge request !3567
-rw-r--r--CHANGELOG1
-rw-r--r--doc/api/tags.md34
-rw-r--r--lib/api/tags.rb14
-rw-r--r--spec/requests/api/tags_spec.rb17
4 files changed, 65 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 8db9a9b0d1e..e0ae6b79751 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,7 @@ v 8.7.0 (unreleased)
- Remove "Congratulations!" tweet button on newly-created project. (Connor Shea)
- Improved UX of the navigation sidebar
- Build status notifications
+ - API: Ability to retrieve a specific tag (Robert Schilling)
v 8.6.5 (unreleased)
- Check permissions when user attempts to import members from another project
diff --git a/doc/api/tags.md b/doc/api/tags.md
index 17d12e9cc62..c451a42b725 100644
--- a/doc/api/tags.md
+++ b/doc/api/tags.md
@@ -38,6 +38,38 @@ Parameters:
]
```
+## Get a single repository tag
+
+Get a specific repository tag determined by its name. It returns 200 together
+with the tag information if the tag exists. It returns 404 if the tag does not
+exist.
+
+Parameters:
+
+- `id` (required) - The ID of a project
+- `tag_name` (required) - The name of the tag
+
+```json
+{
+ "name": "v5.0.0",
+ "message": null,
+ "commit": {
+ "id": "60a8ff033665e1207714d6670fcd7b65304ec02f",
+ "message": "v5.0.0\n",
+ "parent_ids": [
+ "f61c062ff8bcbdb00e0a1b3317a91aed6ceee06b"
+ ],
+ "authored_date": "2015-02-01T21:56:31.000+01:00",
+ "author_name": "Arthur Verschaeve",
+ "author_email": "contact@arthurverschaeve.be",
+ "committed_date": "2015-02-01T21:56:31.000+01:00",
+ "committer_name": "Arthur Verschaeve",
+ "committer_email": "contact@arthurverschaeve.be"
+ },
+ "release": null
+}
+```
+
## Create a new tag
Creates a new tag in the repository that points to the supplied ref.
@@ -148,4 +180,4 @@ Parameters:
"tag_name": "1.0.0",
"description": "Amazing release. Wow"
}
-``` \ No newline at end of file
+```
diff --git a/lib/api/tags.rb b/lib/api/tags.rb
index 2d8a9e51bb9..731a68082ba 100644
--- a/lib/api/tags.rb
+++ b/lib/api/tags.rb
@@ -16,6 +16,20 @@ module API
with: Entities::RepoTag, project: user_project
end
+ # Get a single repository tag
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # tag_name (required) - The name of the tag
+ # Example Request:
+ # GET /projects/:id/repository/tags/:tag_name
+ get ":id/repository/tags/:tag_name", requirements: { tag_name: /.*/ } do
+ tag = user_project.repository.find_tag(params[:tag_name])
+ not_found!('Tag') unless tag
+
+ present tag, with: Entities::RepoTag, project: user_project
+ end
+
# Create tag
#
# Parameters:
diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb
index a15be07ed57..acbd9c3e332 100644
--- a/spec/requests/api/tags_spec.rb
+++ b/spec/requests/api/tags_spec.rb
@@ -40,6 +40,23 @@ describe API::API, api: true do
end
end
+ describe "GET /projects/:id/repository/tags/:tag_name" do
+ let(:tag_name) { project.repository.tag_names.sort.reverse.first }
+
+ it 'should return a specific tag' do
+ get api("/projects/#{project.id}/repository/tags/#{tag_name}", user)
+
+ expect(response.status).to eq(200)
+ expect(json_response['name']).to eq(tag_name)
+ end
+
+ it 'should return 404 for an invalid tag name' do
+ get api("/projects/#{project.id}/repository/tags/foobar", user)
+
+ expect(response.status).to eq(404)
+ end
+ end
+
describe 'POST /projects/:id/repository/tags' do
context 'lightweight tags' do
it 'should create a new tag' do