diff options
author | Micaël Bergeron <mbergeron@gitlab.com> | 2018-02-09 10:32:42 -0500 |
---|---|---|
committer | Micaël Bergeron <mbergeron@gitlab.com> | 2018-02-16 13:51:19 -0500 |
commit | eef63813ea6a9585941be5f079104604d779d440 (patch) | |
tree | c8f821cbcd8750978e781c065847839d13332bab /app | |
parent | dfb14e4d22aa91d9d3fbcee5c7e44ae61bf18c51 (diff) | |
download | gitlab-ce-eef63813ea6a9585941be5f079104604d779d440.tar.gz |
stop ProcessCommitWorker from processing MR merge commit
When a merge request is merged, it creates a commit with the
description of the MR, which may contain references and issue
closing references. As this will be handled in the PostMergeService
anyways, let's ignore merge commit generated from a MR.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/commit.rb | 8 | ||||
-rw-r--r-- | app/workers/process_commit_worker.rb | 12 |
2 files changed, 9 insertions, 11 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 8c960389652..add5fcf0e79 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -417,6 +417,10 @@ class Commit !!(title =~ WIP_REGEX) end + def merged_merge_request?(user) + !!merged_merge_request(user) + end + private def commit_reference(from, referable_commit_id, full: false) @@ -445,10 +449,6 @@ class Commit changes end - def merged_merge_request?(user) - !!merged_merge_request(user) - end - def merged_merge_request_no_cache(user) MergeRequestsFinder.new(user, project_id: project.id).find_by(merge_commit_sha: id) if merge_commit? end diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb index 52eebe475ec..a6330a6c51f 100644 --- a/app/workers/process_commit_worker.rb +++ b/app/workers/process_commit_worker.rb @@ -23,27 +23,25 @@ class ProcessCommitWorker return unless user commit = build_commit(project, commit_hash) - author = commit.author || user - process_commit_message(project, commit, user, author, default) + # this is a GitLab generated commit message, ignore it. + return if commit.merged_merge_request?(user) + process_commit_message(project, commit, user, author, default) update_issue_metrics(commit, author) end def process_commit_message(project, commit, user, author, default = false) closed_issues = default ? commit.closes_issues(user) : [] - unless closed_issues.empty? - close_issues(project, user, author, commit, closed_issues) - end - + close_issues(project, user, author, commit, closed_issues) if closed_issues.any? commit.create_cross_references!(author, closed_issues) end def close_issues(project, user, author, commit, issues) # We don't want to run permission related queries for every single issue, - # therefor we use IssueCollection here and skip the authorization check in + # therefore we use IssueCollection here and skip the authorization check in # Issues::CloseService#execute. IssueCollection.new(issues).updatable_by_user(user).each do |issue| Issues::CloseService.new(project, author) |