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-04-28 23:48:37 +00:00
|
|
|
project.repository.after_create if project.empty_repo?
|
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-08-11 13:22:35 +00:00
|
|
|
Ci::CreatePipelineService.new(project, current_user, @push_data).execute
|
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-05-30 11:46:47 +00:00
|
|
|
unless Gitlab::Git.blank_ref?(params[:newrev])
|
2016-04-15 12:26:27 +00:00
|
|
|
tag_name = Gitlab::Git.ref_name(params[:ref])
|
2014-12-05 21:56:43 +00:00
|
|
|
tag = project.repository.find_tag(tag_name)
|
2016-07-27 15:26:29 +00:00
|
|
|
|
2016-09-27 03:07:31 +00:00
|
|
|
if tag && tag.target == params[:newrev]
|
|
|
|
commit = project.commit(tag.dereferenced_target)
|
2014-12-05 21:56:43 +00:00
|
|
|
commits = [commit].compact
|
|
|
|
message = tag.message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-12 08:09:29 +00:00
|
|
|
Gitlab::DataBuilder::Push.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-08-12 08:09:29 +00:00
|
|
|
Gitlab::DataBuilder::Push.build(
|
|
|
|
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
|