diff options
author | Luka Markušić <luka.markusic@microblink.com> | 2022-06-17 21:10:19 +0200 |
---|---|---|
committer | Luka Markušić <luka.markusic@microblink.com> | 2022-07-30 17:05:17 +0200 |
commit | e6e4513f45689f907fc8143b0ac5183ae1032bd3 (patch) | |
tree | 2eb84cbd5fbfa2afb52f5c57350f7ec71bc1ba21 /pkg | |
parent | 9c6239df3dda06b94ba70787871ca074f651745f (diff) |
Show active branch for recent repo
Split recent repo menu into three columns
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/recent_repos_panel.go | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 71354aac1..94161030d 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -1,24 +1,42 @@ package gui import ( + "fmt" "os" "path/filepath" + "strings" "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/env" + "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" ) +func (gui *Gui) getCurrentBranch(path string) string { + if branch, err := gui.os.Cmd.New( + fmt.Sprintf("git -C %s rev-parse --abbrev-ref HEAD", gui.os.Quote(path)), + ).DontLog().RunWithOutput(); err == nil { + return strings.Trim(branch, "\n") + } + return "" +} + func (gui *Gui) handleCreateRecentReposMenu() error { - recentRepoPaths := gui.c.GetAppState().RecentRepos + // we skip the first one because we're currently in it + recentRepoPaths := gui.c.GetAppState().RecentRepos[1:] + + menuItems := slices.Map(recentRepoPaths, func(path string) *types.MenuItem { + branchName, _ := currentBranches.Load(path) + if icons.IsIconEnabled() { + branchName = icons.BRANCH_ICON + " " + branchName + } - // we won't show the current repo hence the -1 - menuItems := slices.Map(recentRepoPaths[1:], func(path string) *types.MenuItem { return &types.MenuItem{ LabelColumns: []string{ filepath.Base(path), + style.FgCyan.Sprint(branchName), style.FgMagenta.Sprint(path), }, OnPress: func() error { |