2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
class GitTagPushService < BaseService
|
|
|
|
attr_accessor :push_data
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
def execute
|
|
|
|
project.repository.after_create if project.empty_repo?
|
|
|
|
project.repository.before_push_tag
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
@push_data = build_push_data
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
EventCreateService.new.push(project, current_user, push_data)
|
|
|
|
Ci::CreatePipelineService.new(project, current_user, push_data).execute(:push)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
SystemHooksService.new.execute_hooks(build_system_push_data, :tag_push_hooks)
|
|
|
|
project.execute_hooks(push_data.dup, :tag_push_hooks)
|
|
|
|
project.execute_services(push_data.dup, :tag_push_hooks)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size])
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
true
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
def build_push_data
|
2015-04-26 12:48:37 +05:30
|
|
|
commits = []
|
|
|
|
message = nil
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
unless Gitlab::Git.blank_ref?(params[:newrev])
|
2016-06-02 11:05:42 +05:30
|
|
|
tag_name = Gitlab::Git.ref_name(params[:ref])
|
2015-04-26 12:48:37 +05:30
|
|
|
tag = project.repository.find_tag(tag_name)
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2016-11-24 13:41:30 +05:30
|
|
|
if tag && tag.target == params[:newrev]
|
|
|
|
commit = project.commit(tag.dereferenced_target)
|
2015-04-26 12:48:37 +05:30
|
|
|
commits = [commit].compact
|
|
|
|
message = tag.message
|
|
|
|
end
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
Gitlab::DataBuilder::Push.build(
|
|
|
|
project,
|
|
|
|
current_user,
|
|
|
|
params[:oldrev],
|
|
|
|
params[:newrev],
|
|
|
|
params[:ref],
|
|
|
|
commits,
|
|
|
|
message)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def build_system_push_data
|
2016-09-13 17:45:13 +05:30
|
|
|
Gitlab::DataBuilder::Push.build(
|
|
|
|
project,
|
|
|
|
current_user,
|
|
|
|
params[:oldrev],
|
|
|
|
params[:newrev],
|
|
|
|
params[:ref],
|
|
|
|
[],
|
|
|
|
'')
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|