mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-24 08:52:21 +02:00
Only show private repo popup when opening repo for first time
This commit is contained in:
parent
6d0fa8bc29
commit
ced81e11f0
@ -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: []
|
||||
`)
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user