diff --git a/pkg/gui/controllers/helpers/repos_helper.go b/pkg/gui/controllers/helpers/repos_helper.go index 1942bd735..d22230fd9 100644 --- a/pkg/gui/controllers/helpers/repos_helper.go +++ b/pkg/gui/controllers/helpers/repos_helper.go @@ -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 diff --git a/pkg/integration/tests/misc/recent_repos_branch_column.go b/pkg/integration/tests/misc/recent_repos_branch_column.go new file mode 100644 index 000000000..77562102b --- /dev/null +++ b/pkg/integration/tests/misc/recent_repos_branch_column.go @@ -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() + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index c2f536bfa..89ae48de0 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -365,6 +365,7 @@ var tests = []*components.IntegrationTest{ misc.DirenvUnloadsOnBlockedEnvrc, misc.FilterRecentRepos, misc.InitialOpen, + misc.RecentReposBranchColumn, misc.RecentReposColumnWidths, misc.RecentReposOnLaunch, misc.RecentReposWithLongNames,