summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 00:09:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 00:09:34 +0000
commit5781a4966047232d4725f9ee4769c4bd5aed9b26 (patch)
tree0ef2b81a40931ec51f8fdd5284ed9e47cf42a923 /app/workers
parent4d48b3cfcd74bcca0f0f305746f74cf7224dd78b (diff)
downloadgitlab-ce-5781a4966047232d4725f9ee4769c4bd5aed9b26.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/process_commit_worker.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb
index 4039ad45899..9960e812a2f 100644
--- a/app/workers/process_commit_worker.rb
+++ b/app/workers/process_commit_worker.rb
@@ -19,13 +19,12 @@ class ProcessCommitWorker # rubocop:disable Scalability/IdempotentWorker
# commit_hash - Hash containing commit details to use for constructing a
# Commit object without having to use the Git repository.
# default - The data was pushed to the default branch.
- # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id, commit_hash, default = false)
- project = Project.find_by(id: project_id)
+ project = Project.id_in(project_id).first
return unless project
- user = User.find_by(id: user_id)
+ user = User.id_in(user_id).first
return unless user
@@ -35,12 +34,11 @@ class ProcessCommitWorker # rubocop:disable Scalability/IdempotentWorker
process_commit_message(project, commit, user, author, default)
update_issue_metrics(commit, author)
end
- # rubocop: enable CodeReuse/ActiveRecord
def process_commit_message(project, commit, user, author, default = false)
# Ignore closing references from GitLab-generated commit messages.
find_closing_issues = default && !commit.merged_merge_request?(user)
- closed_issues = find_closing_issues ? commit.closes_issues(user) : []
+ closed_issues = find_closing_issues ? issues_to_close(project, commit, user) : []
close_issues(project, user, author, commit, closed_issues) if closed_issues.any?
commit.create_cross_references!(author, closed_issues)
@@ -56,6 +54,12 @@ class ProcessCommitWorker # rubocop:disable Scalability/IdempotentWorker
end
end
+ def issues_to_close(project, commit, user)
+ Gitlab::ClosingIssueExtractor
+ .new(project, user)
+ .closed_by_message(commit.safe_message)
+ end
+
def update_issue_metrics(commit, author)
mentioned_issues = commit.all_references(author).issues