diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-21 15:09:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-21 15:09:07 +0300 |
commit | 2a040e2655fe0a99df61ad0a7bd0c27e68af0c38 (patch) | |
tree | a245cd0d6dd10f185e2fd098e371adc1ea03b72b /app/services/issues | |
parent | a53d2c37c4934f564caa94543dd4cf5af1703e2d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/issues')
-rw-r--r-- | app/services/issues/close_service.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/services/issues/close_service.rb b/app/services/issues/close_service.rb index 14585c2850b..ce955b07648 100644 --- a/app/services/issues/close_service.rb +++ b/app/services/issues/close_service.rb @@ -36,6 +36,8 @@ module Issues execute_hooks(issue, 'close') invalidate_cache_counts(issue, users: issue.assignees) issue.update_project_counter_caches + + store_first_mentioned_in_commit_at(issue, closed_via) if closed_via.is_a?(MergeRequest) end issue @@ -46,5 +48,17 @@ module Issues def create_note(issue, current_commit) SystemNoteService.change_status(issue, issue.project, current_user, issue.state, current_commit) end + + def store_first_mentioned_in_commit_at(issue, merge_request) + return unless Feature.enabled?(:store_first_mentioned_in_commit_on_issue_close, issue.project) + + metrics = issue.metrics + return if metrics.nil? || metrics.first_mentioned_in_commit_at + + first_commit_timestamp = merge_request.commits(limit: 1).first&.date + return unless first_commit_timestamp + + metrics.update!(first_mentioned_in_commit_at: first_commit_timestamp) + end end end |