Commit 822d9aa6 authored by Sean Edge's avatar Sean Edge

Create RepoTag Grape entity and present it when doing stuff with tags via API....

Create RepoTag Grape entity and present it when doing stuff with tags via API. Update API doc for repositories. Add tag message to tag list page in UI. Update Changelog. Update spec to set .gitconfig identity, required for annotated tags.
parent f99b8768
...@@ -4,6 +4,7 @@ v 7.5.0 ...@@ -4,6 +4,7 @@ v 7.5.0
- Fix LDAP authentication for Git HTTP access - Fix LDAP authentication for Git HTTP access
- Fix LDAP config lookup for provider 'ldap' - Fix LDAP config lookup for provider 'ldap'
- Add Atlassian Bamboo CI service (Drew Blessing) - Add Atlassian Bamboo CI service (Drew Blessing)
- Tie up loose ends with annotated tags: API & UI (Sean Edge)
v 7.4.2 v 7.4.2
- Fix internal snippet exposing for unauthenticated users - Fix internal snippet exposing for unauthenticated users
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
= link_to project_commits_path(@project, tag.name), class: "" do = link_to project_commits_path(@project, tag.name), class: "" do
%i.fa.fa-tag %i.fa.fa-tag
= tag.name = tag.name
- if tag.message.present?
 
= tag.message
.pull-right .pull-right
- if can? current_user, :download_code, @project - if can? current_user, :download_code, @project
= render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'btn-grouped btn-group-small' = render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'btn-grouped btn-group-small'
......
...@@ -56,6 +56,7 @@ Parameters: ...@@ -56,6 +56,7 @@ Parameters:
[ [
{ {
"name": "v1.0.0", "name": "v1.0.0",
"message": "Release 1.0.0",
"commit": { "commit": {
"id": "2695effb5807a22ff3d138d593fd856244e155e7", "id": "2695effb5807a22ff3d138d593fd856244e155e7",
"parents": [], "parents": [],
...@@ -67,10 +68,11 @@ Parameters: ...@@ -67,10 +68,11 @@ Parameters:
"committed_date": "2012-05-28T04:42:42-07:00", "committed_date": "2012-05-28T04:42:42-07:00",
"committer_email": "jack@example.com" "committer_email": "jack@example.com"
}, },
"protected": false
} }
] ]
``` ```
The message will be `nil` when creating a lightweight tag otherwise
it will contain the annotation.
It returns 200 if the operation succeed. In case of an error, It returns 200 if the operation succeed. In case of an error,
405 with an explaining error message is returned. 405 with an explaining error message is returned.
......
...@@ -73,6 +73,25 @@ module API ...@@ -73,6 +73,25 @@ module API
end end
end end
class RepoTag < Grape::Entity
expose :name
expose :message do |repo_obj, _options|
if repo_obj.respond_to?(:message)
repo_obj.message
else
nil
end
end
expose :commit do |repo_obj, options|
if repo_obj.respond_to?(:commit)
repo_obj.commit
elsif options[:project]
options[:project].repository.commit(repo_obj.target)
end
end
end
class RepoObject < Grape::Entity class RepoObject < Grape::Entity
expose :name expose :name
......
...@@ -23,7 +23,8 @@ module API ...@@ -23,7 +23,8 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/repository/tags # GET /projects/:id/repository/tags
get ":id/repository/tags" do get ":id/repository/tags" do
present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject, project: user_project present user_project.repo.tags.sort_by(&:name).reverse,
with: Entities::RepoTag, project: user_project
end end
# Create tag # Create tag
...@@ -43,7 +44,7 @@ module API ...@@ -43,7 +44,7 @@ module API
if result[:status] == :success if result[:status] == :success
present result[:tag], present result[:tag],
with: Entities::RepoObject, with: Entities::RepoTag,
project: user_project project: user_project
else else
render_api_error!(result[:message], 400) render_api_error!(result[:message], 400)
......
...@@ -34,21 +34,24 @@ describe API::API, api: true do ...@@ -34,21 +34,24 @@ describe API::API, api: true do
end end
end end
# TODO: fix this test for CI context 'annotated tag' do
#context 'annotated tag' do it 'should create a new annotated tag' do
#it 'should create a new annotated tag' do # Identity must be set in .gitconfig to create annotated tag.
#post api("/projects/#{project.id}/repository/tags", user), repo_path = File.join(Gitlab.config.gitlab_shell.repos_path,
#tag_name: 'v7.1.0', project.path_with_namespace + '.git')
#ref: 'master', system(*%W(git --git-dir=#{repo_path} config user.name #{user.name}))
#message: 'tag message' system(*%W(git --git-dir=#{repo_path} config user.email #{user.email}))
#response.status.should == 201 post api("/projects/#{project.id}/repository/tags", user),
#json_response['name'].should == 'v7.1.0' tag_name: 'v7.1.0',
# The message is not part of the JSON response. ref: 'master',
# Additional changes to the gitlab_git gem may be required. message: 'Release 7.1.0'
# json_response['message'].should == 'tag message'
#end response.status.should == 201
#end json_response['name'].should == 'v7.1.0'
json_response['message'].should == 'Release 7.1.0'
end
end
it 'should deny for user without push access' do it 'should deny for user without push access' do
post api("/projects/#{project.id}/repository/tags", user2), post api("/projects/#{project.id}/repository/tags", user2),
......
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