mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-15 01:56:24 -04:00
Show "HEAD detached at <hash>" in the recent repos menu
A repo with no branch checked out puts a bare short hash in the branch column, where it reads as a branch name. Spell it out the way the worktrees panel already does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a3e940e20e
commit
9e542ff6e0
|
|
@ -119,7 +119,8 @@ func (self *ReposHelper) getCurrentBranch(path string) string {
|
|||
if head.branch != "" {
|
||||
return head.branch
|
||||
}
|
||||
return utils.ShortHash(head.hash)
|
||||
return utils.ResolvePlaceholderString(self.c.Tr.HeadDetachedAt,
|
||||
map[string]string{"hash": utils.ShortHash(head.hash)})
|
||||
}
|
||||
|
||||
// The most that the name and the branch column of the recent repos menu are
|
||||
|
|
|
|||
40
pkg/integration/tests/misc/recent_repos_branch_column.go
Normal file
40
pkg/integration/tests/misc/recent_repos_branch_column.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package misc
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var RecentReposBranchColumn = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "The branch column of the recent repositories menu shows what each repo has checked out",
|
||||
ExtraCmdArgs: []string{},
|
||||
ExtraEnvVars: map[string]string{
|
||||
"SHOW_RECENT_REPOS": "true",
|
||||
},
|
||||
Skip: false,
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
// the first entry is the repo we're in, so it isn't offered
|
||||
current, _ := filepath.Abs(".")
|
||||
onBranch, _ := filepath.Abs("../on-branch")
|
||||
detached, _ := filepath.Abs("../detached")
|
||||
cfg.GetAppState().RecentRepos = []string{current, onBranch, detached}
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("one")
|
||||
shell.CloneNonBare("on-branch")
|
||||
shell.CloneNonBare("detached")
|
||||
shell.RunCommand([]string{"git", "-C", "../detached", "checkout", "--detach"})
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Recent repositories")).
|
||||
Lines(
|
||||
Contains("on-branch").Contains("master").IsSelected(),
|
||||
Contains("detached").MatchesRegexp(`HEAD detached at [0-9a-f]{8}`),
|
||||
Contains("Cancel"),
|
||||
).
|
||||
Cancel()
|
||||
},
|
||||
})
|
||||
|
|
@ -365,6 +365,7 @@ var tests = []*components.IntegrationTest{
|
|||
misc.DirenvUnloadsOnBlockedEnvrc,
|
||||
misc.FilterRecentRepos,
|
||||
misc.InitialOpen,
|
||||
misc.RecentReposBranchColumn,
|
||||
misc.RecentReposColumnWidths,
|
||||
misc.RecentReposOnLaunch,
|
||||
misc.RecentReposWithLongNames,
|
||||
|
|
|
|||
Loading…
Reference in a new issue