diff options
Diffstat (limited to 'app/workers/process_commit_worker.rb')
-rw-r--r-- | app/workers/process_commit_worker.rb | 14 |
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 |