From 9a1c5456747a7b5b218b8b44e4b43396bf7fd705 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 3 Oct 2019 15:07:07 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/services/git/base_hooks_service.rb | 15 ++++++++------- app/services/git/branch_hooks_service.rb | 16 ++++++++-------- app/services/git/branch_push_service.rb | 13 +++++++------ app/services/git/tag_hooks_service.rb | 6 +++--- app/services/git/tag_push_service.rb | 4 +++- 5 files changed, 29 insertions(+), 25 deletions(-) (limited to 'app/services/git') diff --git a/app/services/git/base_hooks_service.rb b/app/services/git/base_hooks_service.rb index 0d320e96b2e..97047d96de1 100644 --- a/app/services/git/base_hooks_service.rb +++ b/app/services/git/base_hooks_service.rb @@ -3,6 +3,7 @@ module Git class BaseHooksService < ::BaseService include Gitlab::Utils::StrongMemoize + include ChangeParams # The N most recent commits to process in a single push payload. PROCESS_COMMIT_LIMIT = 100 @@ -77,20 +78,20 @@ module Git def pipeline_params { - before: params[:oldrev], - after: params[:newrev], - ref: params[:ref], + before: oldrev, + after: newrev, + ref: ref, push_options: params[:push_options] || {}, checkout_sha: Gitlab::DataBuilder::Push.checkout_sha( - project.repository, params[:newrev], params[:ref]) + project.repository, newrev, ref) } end def push_data_params(commits:, with_changed_files: true) { - oldrev: params[:oldrev], - newrev: params[:newrev], - ref: params[:ref], + oldrev: oldrev, + newrev: newrev, + ref: ref, project: project, user: current_user, commits: commits, diff --git a/app/services/git/branch_hooks_service.rb b/app/services/git/branch_hooks_service.rb index c633cff2822..69f1f9eb31f 100644 --- a/app/services/git/branch_hooks_service.rb +++ b/app/services/git/branch_hooks_service.rb @@ -20,15 +20,15 @@ module Git strong_memoize(:commits) do if creating_default_branch? # The most recent PROCESS_COMMIT_LIMIT commits in the default branch - project.repository.commits(params[:newrev], limit: PROCESS_COMMIT_LIMIT) + project.repository.commits(newrev, limit: PROCESS_COMMIT_LIMIT) elsif creating_branch? # Use the pushed commits that aren't reachable by the default branch # as a heuristic. This may include more commits than are actually # pushed, but that shouldn't matter because we check for existing # cross-references later. - project.repository.commits_between(project.default_branch, params[:newrev]) + project.repository.commits_between(project.default_branch, newrev) elsif updating_branch? - project.repository.commits_between(params[:oldrev], params[:newrev]) + project.repository.commits_between(oldrev, newrev) else # removing branch [] end @@ -70,7 +70,7 @@ module Git def branch_update_hooks # Update the bare repositories info/attributes file using the contents of # the default branch's .gitattributes file - project.repository.copy_gitattributes(params[:ref]) if default_branch? + project.repository.copy_gitattributes(ref) if default_branch? end def branch_change_hooks @@ -118,7 +118,7 @@ module Git # https://gitlab.com/gitlab-org/gitlab-foss/issues/59257 def creating_branch? strong_memoize(:creating_branch) do - Gitlab::Git.blank_ref?(params[:oldrev]) || + Gitlab::Git.blank_ref?(oldrev) || !project.repository.branch_exists?(branch_name) end end @@ -128,7 +128,7 @@ module Git end def removing_branch? - Gitlab::Git.blank_ref?(params[:newrev]) + Gitlab::Git.blank_ref?(newrev) end def creating_default_branch? @@ -137,7 +137,7 @@ module Git def count_commits_in_branch strong_memoize(:count_commits_in_branch) do - project.repository.commit_count_for_ref(params[:ref]) + project.repository.commit_count_for_ref(ref) end end @@ -148,7 +148,7 @@ module Git end def branch_name - strong_memoize(:branch_name) { Gitlab::Git.ref_name(params[:ref]) } + strong_memoize(:branch_name) { Gitlab::Git.ref_name(ref) } end def upstream_commit_ids(commits) diff --git a/app/services/git/branch_push_service.rb b/app/services/git/branch_push_service.rb index 7adc3320e06..da45bcc7eaa 100644 --- a/app/services/git/branch_push_service.rb +++ b/app/services/git/branch_push_service.rb @@ -4,6 +4,7 @@ module Git class BranchPushService < ::BaseService include Gitlab::Access include Gitlab::Utils::StrongMemoize + include ChangeParams # This method will be called after each git update # and only if the provided user and project are present in GitLab. @@ -19,7 +20,7 @@ module Git # 6. Checks if the project's main language has changed # def execute - return unless Gitlab::Git.branch_ref?(params[:ref]) + return unless Gitlab::Git.branch_ref?(ref) enqueue_update_mrs enqueue_detect_repository_languages @@ -38,9 +39,9 @@ module Git UpdateMergeRequestsWorker.perform_async( project.id, current_user.id, - params[:oldrev], - params[:newrev], - params[:ref] + oldrev, + newrev, + ref ) end @@ -69,11 +70,11 @@ module Git end def removing_branch? - Gitlab::Git.blank_ref?(params[:newrev]) + Gitlab::Git.blank_ref?(newrev) end def branch_name - strong_memoize(:branch_name) { Gitlab::Git.ref_name(params[:ref]) } + strong_memoize(:branch_name) { Gitlab::Git.ref_name(ref) } end def default_branch? diff --git a/app/services/git/tag_hooks_service.rb b/app/services/git/tag_hooks_service.rb index e5b109c79d6..0e5e1bbc992 100644 --- a/app/services/git/tag_hooks_service.rb +++ b/app/services/git/tag_hooks_service.rb @@ -18,12 +18,12 @@ module Git def tag strong_memoize(:tag) do - next if Gitlab::Git.blank_ref?(params[:newrev]) + next if Gitlab::Git.blank_ref?(newrev) - tag_name = Gitlab::Git.ref_name(params[:ref]) + tag_name = Gitlab::Git.ref_name(ref) tag = project.repository.find_tag(tag_name) - tag if tag && tag.target == params[:newrev] + tag if tag && tag.target == newrev end end diff --git a/app/services/git/tag_push_service.rb b/app/services/git/tag_push_service.rb index ee4166dccd0..9a266f7d74c 100644 --- a/app/services/git/tag_push_service.rb +++ b/app/services/git/tag_push_service.rb @@ -2,8 +2,10 @@ module Git class TagPushService < ::BaseService + include ChangeParams + def execute - return unless Gitlab::Git.tag_ref?(params[:ref]) + return unless Gitlab::Git.tag_ref?(ref) project.repository.before_push_tag TagHooksService.new(project, current_user, params).execute -- cgit v1.2.3