diff options
author | Nick Thomas <nick@gitlab.com> | 2019-03-22 16:44:14 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-03-25 12:56:46 +0000 |
commit | 558e946263a58075d396a89427f44843e5fb789f (patch) | |
tree | 277ec60e6bf50ea606824225bae4a8e46af36124 /app | |
parent | ed99296edfd09cc2fad187458c18f5c174804270 (diff) | |
download | gitlab-ce-558e946263a58075d396a89427f44843e5fb789f.tar.gz |
Rename GitTagPushService -> Git::TagPushService
Diffstat (limited to 'app')
-rw-r--r-- | app/services/git/tag_push_service.rb | 68 | ||||
-rw-r--r-- | app/services/git_tag_push_service.rb | 66 | ||||
-rw-r--r-- | app/workers/post_receive.rb | 2 |
3 files changed, 69 insertions, 67 deletions
diff --git a/app/services/git/tag_push_service.rb b/app/services/git/tag_push_service.rb new file mode 100644 index 00000000000..318dfd4f886 --- /dev/null +++ b/app/services/git/tag_push_service.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +module Git + class TagPushService < BaseService + attr_accessor :push_data + + def execute + project.repository.after_create if project.empty_repo? + project.repository.before_push_tag + + @push_data = build_push_data + + EventCreateService.new.push(project, current_user, push_data) + Ci::CreatePipelineService.new(project, current_user, push_data).execute(:push, pipeline_options) + + 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) + + ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size]) + + true + end + + private + + def build_push_data + commits = [] + message = nil + + unless Gitlab::Git.blank_ref?(params[:newrev]) + tag_name = Gitlab::Git.ref_name(params[:ref]) + tag = project.repository.find_tag(tag_name) + + if tag && tag.target == params[:newrev] + commit = project.commit(tag.dereferenced_target) + commits = [commit].compact + message = tag.message + end + end + + Gitlab::DataBuilder::Push.build( + project, + current_user, + params[:oldrev], + params[:newrev], + params[:ref], + commits, + message, + push_options: params[:push_options] || []) + end + + def build_system_push_data + Gitlab::DataBuilder::Push.build( + project, + current_user, + params[:oldrev], + params[:newrev], + params[:ref], + [], + '') + end + + def pipeline_options + {} # to be overridden in EE + end + end +end diff --git a/app/services/git_tag_push_service.rb b/app/services/git_tag_push_service.rb deleted file mode 100644 index e39b3603c6c..00000000000 --- a/app/services/git_tag_push_service.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -class GitTagPushService < BaseService - attr_accessor :push_data - - def execute - project.repository.after_create if project.empty_repo? - project.repository.before_push_tag - - @push_data = build_push_data - - EventCreateService.new.push(project, current_user, push_data) - Ci::CreatePipelineService.new(project, current_user, push_data).execute(:push, pipeline_options) - - 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) - - ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size]) - - true - end - - private - - def build_push_data - commits = [] - message = nil - - unless Gitlab::Git.blank_ref?(params[:newrev]) - tag_name = Gitlab::Git.ref_name(params[:ref]) - tag = project.repository.find_tag(tag_name) - - if tag && tag.target == params[:newrev] - commit = project.commit(tag.dereferenced_target) - commits = [commit].compact - message = tag.message - end - end - - Gitlab::DataBuilder::Push.build( - project, - current_user, - params[:oldrev], - params[:newrev], - params[:ref], - commits, - message, - push_options: params[:push_options] || []) - end - - def build_system_push_data - Gitlab::DataBuilder::Push.build( - project, - current_user, - params[:oldrev], - params[:newrev], - params[:ref], - [], - '') - end - - def pipeline_options - {} # to be overridden in EE - end -end diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index bbd4ab159e4..e721f14ddf5 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -38,7 +38,7 @@ class PostReceive post_received.changes_refs do |oldrev, newrev, ref| if Gitlab::Git.tag_ref?(ref) - GitTagPushService.new( + Git::TagPushService.new( post_received.project, @user, oldrev: oldrev, |