diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-02-11 21:02:53 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-02-11 21:02:53 +1100 |
commit | 3d343e9b574a2c99ebf5b30dc9a4dac2886f6d73 (patch) | |
tree | ef6b2f8c08a29349bcc56a16260dfefdb3ee872d /pkg/gui/recent_repos_panel.go | |
parent | a3656154906c1117f9c9bbe100aa585e43417897 (diff) | |
parent | 3a607061a2303d9f45d308de652fbebe7300b43c (diff) |
Merge branch 'master' into feature/rebasing
Diffstat (limited to 'pkg/gui/recent_repos_panel.go')
-rw-r--r-- | pkg/gui/recent_repos_panel.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 13c26ccd0..e14a917eb 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -14,7 +14,7 @@ type recentRepo struct { path string } -// GetDisplayStrings is a function. +// GetDisplayStrings returns the path from a recent repo. func (r *recentRepo) GetDisplayStrings() []string { yellow := color.New(color.FgMagenta) base := filepath.Base(r.path) @@ -55,16 +55,22 @@ func (gui *Gui) updateRecentRepoList() error { if err != nil { return err } - gui.Config.GetAppState().RecentRepos = newRecentReposList(recentRepos, currentRepo) + known, recentRepos := newRecentReposList(recentRepos, currentRepo) + gui.Config.SetIsNewRepo(known) + gui.Config.GetAppState().RecentRepos = recentRepos return gui.Config.SaveAppState() } -func newRecentReposList(recentRepos []string, currentRepo string) []string { +// newRecentReposList returns a new repo list with a new entry but only when it doesn't exist yet +func newRecentReposList(recentRepos []string, currentRepo string) (bool, []string) { + isNew := true newRepos := []string{currentRepo} for _, repo := range recentRepos { if repo != currentRepo { newRepos = append(newRepos, repo) + } else { + isNew = false } } - return newRepos + return isNew, newRepos } |