Class: Commits::TagService

Inherits:
BaseService show all
Defined in:
app/services/commits/tag_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(commit) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/commits/tag_service.rb', line 5

def execute(commit)
  unless params[:tag_name]
    return error('Missing parameter tag_name')
  end

  tag_name = params[:tag_name]
  message = params[:tag_message]

  result = Tags::CreateService
    .new(commit.project, current_user)
    .execute(tag_name, commit.sha, message)

  if result[:status] == :success
    tag = result[:tag]
    SystemNoteService.tag_commit(commit, commit.project, current_user, tag.name)
  end

  result
end