summaryrefslogtreecommitdiffstats
path: root/app/models/changeset.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-10-05 12:10:33 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-10-05 12:10:33 +0000
commita5675463352040ae8e63b0ba6c20a27dbfefc0d3 (patch)
tree5c5d97326aa0a81d96edee9563e2e90cf70d4a6d /app/models/changeset.rb
parent8b678837a353747f6f4fcce343c603daf1e07fbe (diff)
downloadredmine-a5675463352040ae8e63b0ba6c20a27dbfefc0d3.tar.gz
redmine-a5675463352040ae8e63b0ba6c20a27dbfefc0d3.zip
Don't link multiple changesets from the same commit multiple times (#17931).
git-svn-id: http://svn.redmine.org/redmine/trunk@13427 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/changeset.rb')
-rw-r--r--app/models/changeset.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index fea170ddc..cf58c6e07 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -130,7 +130,7 @@ class Changeset < ActiveRecord::Base
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
- if issue
+ if issue && !issue_linked_to_same_commit?(issue)
referenced_issues << issue
# Don't update issues or log time when importing old commits
unless repository.created_on && committed_on && committed_on < repository.created_on
@@ -214,6 +214,12 @@ class Changeset < ActiveRecord::Base
private
+ # Returns true if the issue is already linked to the same commit
+ # from a different repository
+ def issue_linked_to_same_commit?(issue)
+ repository.same_commits_in_scope(issue.changesets, self).any?
+ end
+
# Updates the +issue+ according to +action+
def fix_issue(issue, action)
# the issue may have been updated by the closure of another one (eg. duplicate)