From d0336fe16f3a365eb9bfff1086a4c02277e1f5dd Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Fri, 27 Mar 2020 22:53:50 +1100 Subject: [PATCH] better presentation of remotes --- pkg/commands/git.go | 5 ++--- pkg/commands/remote.go | 16 ---------------- pkg/commands/stash_entry.go | 10 ++-------- pkg/gui/presentation/remotes.go | 8 +++++++- pkg/gui/presentation/stash_entries.go | 2 +- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 803cfe2d4..3b49a254e 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -170,9 +170,8 @@ func (c *GitCommand) GetStashEntries() []*StashEntry { func stashEntryFromLine(line string, index int) *StashEntry { return &StashEntry{ - Name: line, - Index: index, - DisplayString: line, + Name: line, + Index: index, } } diff --git a/pkg/commands/remote.go b/pkg/commands/remote.go index b3c144b65..1dc9f7e7f 100644 --- a/pkg/commands/remote.go +++ b/pkg/commands/remote.go @@ -1,24 +1,8 @@ package commands -import ( - "fmt" - - "github.com/fatih/color" - "github.com/jesseduffield/lazygit/pkg/utils" -) - // Remote : A git remote type Remote struct { Name string Urls []string - Selected bool Branches []*RemoteBranch } - -// GetDisplayStrings returns the display string of a remote -func (r *Remote) GetDisplayStrings(isFocused bool) []string { - - branchCount := len(r.Branches) - - return []string{r.Name, utils.ColoredString(fmt.Sprintf("%d branches", branchCount), color.FgBlue)} -} diff --git a/pkg/commands/stash_entry.go b/pkg/commands/stash_entry.go index a47200fd4..94e4417d4 100644 --- a/pkg/commands/stash_entry.go +++ b/pkg/commands/stash_entry.go @@ -2,12 +2,6 @@ package commands // StashEntry : A git stash entry type StashEntry struct { - Index int - Name string - DisplayString string -} - -// GetDisplayStrings returns the display string of branch -func (s *StashEntry) GetDisplayStrings(isFocused bool) []string { - return []string{s.DisplayString} + Index int + Name string } diff --git a/pkg/gui/presentation/remotes.go b/pkg/gui/presentation/remotes.go index 24fcd0b97..3adfad858 100644 --- a/pkg/gui/presentation/remotes.go +++ b/pkg/gui/presentation/remotes.go @@ -1,7 +1,11 @@ package presentation import ( + "fmt" + + "github.com/fatih/color" "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/utils" ) func GetRemoteListDisplayStrings(remotes []*commands.Remote) [][]string { @@ -16,5 +20,7 @@ func GetRemoteListDisplayStrings(remotes []*commands.Remote) [][]string { // getRemoteDisplayStrings returns the display string of branch func getRemoteDisplayStrings(r *commands.Remote) []string { - return []string{r.Name} + branchCount := len(r.Branches) + + return []string{r.Name, utils.ColoredString(fmt.Sprintf("%d branches", branchCount), color.FgBlue)} } diff --git a/pkg/gui/presentation/stash_entries.go b/pkg/gui/presentation/stash_entries.go index 8598b5e5f..a5557a433 100644 --- a/pkg/gui/presentation/stash_entries.go +++ b/pkg/gui/presentation/stash_entries.go @@ -16,5 +16,5 @@ func GetStashEntryListDisplayStrings(stashEntries []*commands.StashEntry) [][]st // getStashEntryDisplayStrings returns the display string of branch func getStashEntryDisplayStrings(s *commands.StashEntry) []string { - return []string{s.DisplayString} + return []string{s.Name} }