1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Change the way commits are indexed for revision graph (#42762).

The original approach resulted in orphan commits on the page being displayed on the first branch, and in unnecessary offsets.
Solution: Always begin indexing from the latest commit, then index the heads present on the page, and finally index the orphan commits present on the page.

Patch by Leonid Murin (user:murin).


git-svn-id: https://svn.redmine.org/redmine/trunk@24257 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2026-01-05 03:50:57 +00:00
parent 26fb9102d5
commit fc9d1145be

View File

@ -298,14 +298,18 @@ module RepositoriesHelper
}
end
heads.sort_by!(&:to_s)
space = nil
# Process commits starting from the latest
space = index_head(0, commits.first, commits_by_scmid)
# Process commits from heads
heads.each do |head|
if commits_by_scmid.include?(head.scmid) && commits_by_scmid[head.scmid][:space].nil?
space = index_head((space || -1) + 1, head, commits_by_scmid)
space = index_head(space + 1, head, commits_by_scmid)
end
end
# when no head matched anything use first commit
space ||= index_head(0, commits.first, commits_by_scmid)
# Process orphan commits
while (commit = commits.find { |commit| commits_by_scmid[commit.scmid][:space].nil? })
space = index_head(space + 1, commit, commits_by_scmid)
end
return commits_by_scmid, space
end