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
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
EventCreateService.new.push(project, current_user, @push_data)
|
|
|
|
SystemHooksService.new.execute_hooks(build_system_push_data.dup, :tag_push_hooks)
|
2014-09-02 18:07:02 +05:30
|
|
|
project.execute_hooks(@push_data.dup, :tag_push_hooks)
|
2015-04-26 12:48:37 +05:30
|
|
|
project.execute_services(@push_data.dup, :tag_push_hooks)
|
2016-06-02 11:05:42 +05:30
|
|
|
CreateCommitBuildsService.new.execute(project, current_user, @push_data)
|
2015-09-11 14:41:01 +05:30
|
|
|
ProjectCacheWorker.perform_async(project.id)
|
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-02 11:05:42 +05:30
|
|
|
if !Gitlab::Git.blank_ref?(params[:newrev])
|
|
|
|
tag_name = Gitlab::Git.ref_name(params[:ref])
|
2015-04-26 12:48:37 +05:30
|
|
|
tag = project.repository.find_tag(tag_name)
|
2016-06-02 11:05:42 +05:30
|
|
|
if tag && tag.target == params[:newrev]
|
2015-09-11 14:41:01 +05:30
|
|
|
commit = project.commit(tag.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
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
Gitlab::PushDataBuilder.
|
2016-06-02 11:05:42 +05:30
|
|
|
build(project, current_user, params[:oldrev], params[:newrev], params[:ref], commits, message)
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_system_push_data
|
|
|
|
Gitlab::PushDataBuilder.
|
|
|
|
build(project, current_user, params[:oldrev], params[:newrev], params[:ref], [], '')
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|