From 8fd0684c5692f3d013c96194a4fdbcb89323f6bd Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 14 Nov 2026 13:29:22 +0100 Subject: [PATCH] Add a test showing that the branches panel has no hash or subject for a detached HEAD Co-Authored-By: Claude Opus 5.5 --- .../branch/detached_head_hash_and_subject.go | 30 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 31 insertions(+) create mode 100644 pkg/integration/tests/branch/detached_head_hash_and_subject.go diff --git a/pkg/integration/tests/branch/detached_head_hash_and_subject.go b/pkg/integration/tests/branch/detached_head_hash_and_subject.go new file mode 100644 index 000000000..e0c729b89 --- /dev/null +++ b/pkg/integration/tests/branch/detached_head_hash_and_subject.go @@ -0,0 +1,30 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var DetachedHeadHashAndSubject = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Show the commit hash and subject of a detached HEAD in the branches panel", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + Checkout("HEAD^") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Press(keys.Universal.NextScreenMode). + Lines( + /* EXPECTED: + MatchesRegexp(`^ \* [0-9a-f]{8} \(HEAD detached at [0-9a-f]+\) {3}commit-02$`).IsSelected(), + ACTUAL: */ + MatchesRegexp(`^ \* {10}\(HEAD detached at [0-9a-f]+\) {3}$`).IsSelected(), + MatchesRegexp(`[0-9a-f]{8} master +commit-03$`), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 550d6bae7..7286c20a8 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -70,6 +70,7 @@ var tests = []*components.IntegrationTest{ branch.DeleteRemoteBranchWithDifferentName, branch.DeleteWhileFiltering, branch.DetachedHead, + branch.DetachedHeadHashAndSubject, branch.MergeFastForward, branch.MergeIntoDetachedHead, branch.MergeNonFastForward,