From 29024fda89820f9990498352c68ed3e5e5b88063 Mon Sep 17 00:00:00 2001 From: murin Date: Tue, 20 May 2025 12:53:08 +0300 Subject: [PATCH 2/3] Change the way commits are indexed for revision graph 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. Partially relates to #10954#note-5 --- app/helpers/repositories_helper.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 67b19c2dd..6ed17c692 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -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 -- 2.50.1