2016-04-15 12:26:27 +00:00
|
|
|
class GitTagPushService < BaseService
|
|
|
|
attr_accessor :push_data
|
2014-03-13 09:37:13 +00:00
|
|
|
|
2016-04-15 12:26:27 +00:00
|
|
|
def execute
|
2016-03-08 16:38:23 +00:00
|
|
|
project.repository.before_push_tag
|
2014-12-05 21:56:43 +00:00
|
|
|
|
2016-04-15 12:26:27 +00:00
|
|
|
@push_data = build_push_data
|
2014-03-13 09:37:13 +00:00
|
|
|
|
2016-04-15 12:26:27 +00:00
|
|
|
EventCreateService.new.push(project, current_user, @push_data)
|
2016-04-15 11:08:22 +00:00
|
|
|
SystemHooksService.new.execute_hooks(build_system_push_data.dup, :tag_push_hooks)
|
2014-03-05 20:23:49 +00:00
|
|
|
project.execute_hooks(@push_data.dup, :tag_push_hooks)
|
2015-02-20 13:49:36 +00:00
|
|
|
project.execute_services(@push_data.dup, :tag_push_hooks)
|
2016-04-15 12:26:27 +00:00
|
|
|
CreateCommitBuildsService.new.execute(project, current_user, @push_data)
|
2015-07-17 12:50:03 +00:00
|
|
|
ProjectCacheWorker.perform_async(project.id)
|
2015-03-13 13:55:38 +00:00
|
|
|
|
2015-01-11 06:18:14 +00:00
|
|
|
true
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-04-15 12:26:27 +00:00
|
|
|
def build_push_data
|
2014-12-05 21:56:43 +00:00
|
|
|
commits = []
|
|
|
|
message = nil
|
|
|
|
|
2016-04-15 12:26:27 +00:00
|
|
|
if !Gitlab::Git.blank_ref?(params[:newrev])
|
|
|
|
tag_name = Gitlab::Git.ref_name(params[:ref])
|
2014-12-05 21:56:43 +00:00
|
|
|
tag = project.repository.find_tag(tag_name)
|
2016-04-15 12:26:27 +00:00
|
|
|
if tag && tag.target == params[:newrev]
|
2015-04-21 13:13:40 +00:00
|
|
|
commit = project.commit(tag.target)
|
2014-12-05 21:56:43 +00:00
|
|
|
commits = [commit].compact
|
|
|
|
message = tag.message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Gitlab::PushDataBuilder.
|
2016-04-15 12:26:27 +00:00
|
|
|
build(project, current_user, params[:oldrev], params[:newrev], params[:ref], commits, message)
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|
2016-04-15 11:08:22 +00:00
|
|
|
|
2016-04-15 12:26:27 +00:00
|
|
|
def build_system_push_data
|
2016-04-15 11:08:22 +00:00
|
|
|
Gitlab::PushDataBuilder.
|
2016-04-15 12:26:27 +00:00
|
|
|
build_system(project, current_user, params[:oldrev], params[:newrev], params[:ref])
|
2016-04-15 11:08:22 +00:00
|
|
|
end
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|