diff options
author | mjarkk <mkopenga@gmail.com> | 2018-12-06 22:05:16 +0100 |
---|---|---|
committer | mjarkk <mkopenga@gmail.com> | 2018-12-06 22:05:16 +0100 |
commit | ced81e11f048a954b707996d78487e3a6cabd569 (patch) | |
tree | dd159e14e73178b37bf5062f2f2e4b4e660a2173 /pkg | |
parent | 6d0fa8bc2926af9c17c7546c447613ae21ef19fc (diff) |
Only show private repo popup when opening repo for first time
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/config/app_config.go | 8 | ||||
-rw-r--r-- | pkg/gui/gui.go | 2 | ||||
-rw-r--r-- | pkg/gui/recent_repos_panel.go | 18 |
3 files changed, 24 insertions, 4 deletions
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index f789349b4..c01bd7df8 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -236,14 +236,16 @@ confirmOnQuit: false // AppState stores data between runs of the app like when the last update check // was performed and which other repos have been checked out type AppState struct { - LastUpdateCheck int64 - RecentRepos []string + LastUpdateCheck int64 + RecentRepos []string + RecentPrivateRepos []string } func getDefaultAppState() []byte { return []byte(` lastUpdateCheck: 0 - recentRepos: [] + recentRepos: [] + RecentPrivateRepos: [] `) } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index aab73e738..e3d80df12 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -443,7 +443,7 @@ func (gui *Gui) Run() error { go func() { err := gui.fetch(g, g.CurrentView(), false) - if err != nil && strings.Contains(err.Error(), "exit status 128") { + if err != nil && strings.Contains(err.Error(), "exit status 128") && gui.canShowIsPrivateRepo() { _ = gui.createConfirmationPanel(g, g.CurrentView(), gui.Tr.SLocalize("NoAutomaticGitFetchTitle"), gui.Tr.SLocalize("NoAutomaticGitFetchBody"), nil, nil) } else { gui.goEvery(g, time.Second*60, func(g *gocui.Gui) error { diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 98da6a9c2..2b7d05f0a 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -59,6 +59,24 @@ func (gui *Gui) updateRecentRepoList() error { return gui.Config.SaveAppState() } +// canShowIsPrivateRepo returns true if a private repo is never opend before in lazygit +func (gui *Gui) canShowIsPrivateRepo() bool { + repos := gui.Config.GetAppState().RecentPrivateRepos + currentRepo, err := os.Getwd() + for _, repo := range repos { + if currentRepo == repo { + return false + } + } + if err != nil { + return true + } + gui.Config.GetAppState().RecentPrivateRepos = newRecentReposList(repos, currentRepo) + _ = gui.Config.SaveAppState() + return true +} + +// newRecentReposList returns a new repo list with a new entry but only when it doesn't exist yet func newRecentReposList(recentRepos []string, currentRepo string) []string { newRepos := []string{currentRepo} for _, repo := range recentRepos { |