summaryrefslogtreecommitdiff
path: root/app/services/git_push_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/git_push_service.rb')
-rw-r--r--app/services/git_push_service.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index 81535450ac1..0a73244774a 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -78,24 +78,29 @@ class GitPushService
# For push with 1k commits it prevents 900+ requests in database
author = nil
+ # Keep track of the issues that will be actually closed because they are on a default branch.
+ # Hence, when creating cross-reference notes, the not-closed issues (on non-default branches)
+ # will also have cross-reference.
+ actually_closed_issues = []
+
if issues_to_close.present? && is_default_branch
author ||= commit_user(commit)
-
+ actually_closed_issues = issues_to_close
issues_to_close.each do |issue|
Issues::CloseService.new(project, author, {}).execute(issue, commit)
end
end
if project.default_issues_tracker?
- create_cross_reference_notes(commit, issues_to_close)
+ create_cross_reference_notes(commit, actually_closed_issues)
end
end
end
def create_cross_reference_notes(commit, issues_to_close)
- # Create cross-reference notes for any other references. Omit any issues that were referenced in an
- # issue-closing phrase, or have already been mentioned from this commit (probably from this commit
- # being pushed to a different branch).
+ # Create cross-reference notes for any other references than those given in issues_to_close.
+ # Omit any issues that were referenced in an issue-closing phrase, or have already been
+ # mentioned from this commit (probably from this commit being pushed to a different branch).
refs = commit.references(project, user) - issues_to_close
refs.reject! { |r| commit.has_mentioned?(r) }