Commit 1e6766f9 authored by Sean Edge's avatar Sean Edge

Add CreateTagService. Use new service to allow tag creation through API.

parent 3e1853c5
class CreateTagService
def execute(project, tag_name, ref, current_user)
repository = project.repository
repository.add_tag(tag_name, ref)
new_tag = repository.find_tag(tag_name)
if new_tag
Event.create_ref_event(project, current_user, new_tag, 'add', 'refs/tags')
end
new_tag
end
end
......@@ -25,6 +25,22 @@ module API
present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject, project: user_project
end
# Create tag
#
# Parameters:
# id (required) - The ID of a project
# tag_name (required) - The name of the tag
# ref (required) - Create tag from commit sha or branch
# Example Request:
# POST /projects/:id/repository/tags
post ':id/repository/tags' do
authorize_push_project
@tag = CreateTagService.new.execute(user_project, params[:tag_name],
params[:ref], current_user)
present @tag, with: Entities::RepoObject, project: user_project
end
# Get a project repository tree
#
# Parameters:
......
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