1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

add recent repos menu option

This commit is contained in:
Jesse Duffield
2018-09-19 19:15:29 +10:00
parent 768b9453f8
commit e91fb21233
5 changed files with 74 additions and 40 deletions

View File

@@ -317,41 +317,6 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return gui.resizeCurrentPopupPanel(g)
}
func newRecentReposList(recentRepos []string, currentRepo string) []string {
newRepos := []string{currentRepo}
for _, repo := range recentRepos {
if repo != currentRepo {
newRepos = append(newRepos, repo)
}
}
return newRepos
}
// updateRecentRepoList registers the fact that we opened lazygit in this repo,
// so that we can open the same repo via a 'recent repos' menu
func (gui *Gui) updateRecentRepoList() error {
recentRepos := gui.Config.GetAppState().RecentRepos
currentRepo, err := os.Getwd()
if err != nil {
return err
}
gui.Config.GetAppState().RecentRepos = newRecentReposList(recentRepos, currentRepo)
return gui.Config.SaveAppState()
}
func (gui *Gui) handleSwitchRepo(g *gocui.Gui, v *gocui.View) error {
newRepo := gui.Config.GetAppState().RecentRepos[1]
if err := os.Chdir(newRepo); err != nil {
return err
}
newGitCommand, err := commands.NewGitCommand(gui.Log, gui.OSCommand, gui.Tr)
if err != nil {
return err
}
gui.GitCommand = newGitCommand
return gui.Errors.ErrSwitchRepo
}
func (gui *Gui) promptAnonymousReporting() error {
return gui.createConfirmationPanel(gui.g, nil, gui.Tr.SLocalize("AnonymousReportingTitle"), gui.Tr.SLocalize("AnonymousReportingPrompt"), func(g *gocui.Gui, v *gocui.View) error {
return gui.Config.WriteToUserConfig("reporting", "on")