From cee602c029f10e59b1e9eb0d4a11821ef0292036 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 28 Sep 2026 09:28:32 +0200 Subject: [PATCH] Demonstrate that the graph continues the line below a root commit If a root commit isn't the last one in the list, the graph draws a vertical line below it in every row that follows, although nothing comes after a root commit. This happens in repos with more than one root commit, for example when showing all branches of a repo with a gh-pages branch, or after merging an unrelated history. Also, a commit that no line leads to is placed to the right of the lines that ended in the row before it, although their columns are free again. Co-Authored-By: Claude Opus 5.5 (1M context) --- pkg/gui/presentation/graph/graph_test.go | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/pkg/gui/presentation/graph/graph_test.go b/pkg/gui/presentation/graph/graph_test.go index f0cafca1c..35fc7a620 100644 --- a/pkg/gui/presentation/graph/graph_test.go +++ b/pkg/gui/presentation/graph/graph_test.go @@ -94,6 +94,48 @@ func TestRenderCommitGraph(t *testing.T) { 5 ○───╯ │ 6 ○ ╭───╯`, }, + { + name: "with a root commit followed by an unrelated history", + commitOpts: []models.NewCommitOpts{ + {Hash: "1", Parents: []string{"2"}}, + {Hash: "2"}, + {Hash: "A", Parents: []string{"B"}}, + {Hash: "B"}, + }, + /* EXPECTED: + expectedOutput: ` + 1 ○ + 2 ○ + A ○ + B ○`, + ACTUAL: */ + expectedOutput: ` + 1 ○ + 2 ○ + A │ ○ + B │ ○`, + }, + { + name: "with a merge of an unrelated history", + commitOpts: []models.NewCommitOpts{ + {Hash: "1", Parents: []string{"2", "A"}}, + {Hash: "2", Parents: []string{"3"}}, + {Hash: "A"}, + {Hash: "3"}, + }, + /* EXPECTED: + expectedOutput: ` + 1 ◎─╮ + 2 ○ │ + A │ ○ + 3 ○`, + ACTUAL: */ + expectedOutput: ` + 1 ◎─╮ + 2 ○ │ + A │ ○ + 3 ○ │`, + }, { name: "with a path that has room to move to the left and continues", commitOpts: []models.NewCommitOpts{ @@ -528,6 +570,9 @@ func TestGetNextPipes(t *testing.T) { Parents: []string{}, }), expected: []Pipe{ + /* EXPECTED: + {fromPos: 0, toPos: 0, fromHash: pool("root"), toHash: pool(models.EmptyTreeCommitHash), kind: STARTS, style: &style.FgDefault}, + ACTUAL: */ {fromPos: 1, toPos: 1, fromHash: pool("root"), toHash: pool(models.EmptyTreeCommitHash), kind: STARTS, style: &style.FgDefault}, }, },