mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
allow entering and returning from submodule
This commit is contained in:
@@ -17,24 +17,14 @@ func (gui *Gui) handleCreateRecentReposMenu() error {
|
||||
// we won't show the current repo hence the -1
|
||||
menuItems := make([]*menuItem, reposCount-1)
|
||||
for i, path := range recentRepoPaths[1:reposCount] {
|
||||
innerPath := path
|
||||
path := path // cos we're closing over the loop variable
|
||||
menuItems[i] = &menuItem{
|
||||
displayStrings: []string{
|
||||
filepath.Base(innerPath),
|
||||
yellow.Sprint(innerPath),
|
||||
filepath.Base(path),
|
||||
yellow.Sprint(path),
|
||||
},
|
||||
onPress: func() error {
|
||||
env.UnsetGitDirEnvs()
|
||||
if err := os.Chdir(innerPath); err != nil {
|
||||
return err
|
||||
}
|
||||
newGitCommand, err := commands.NewGitCommand(gui.Log, gui.OSCommand, gui.Tr, gui.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gui.GitCommand = newGitCommand
|
||||
gui.State.Modes.Filtering.Path = ""
|
||||
return gui.Errors.ErrSwitchRepo
|
||||
return gui.dispatchSwitchToRepo(path)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -42,6 +32,20 @@ func (gui *Gui) handleCreateRecentReposMenu() error {
|
||||
return gui.createMenu(gui.Tr.SLocalize("RecentRepos"), menuItems, createMenuOptions{showCancel: true})
|
||||
}
|
||||
|
||||
func (gui *Gui) dispatchSwitchToRepo(path string) error {
|
||||
env.UnsetGitDirEnvs()
|
||||
if err := os.Chdir(path); err != nil {
|
||||
return err
|
||||
}
|
||||
newGitCommand, err := commands.NewGitCommand(gui.Log, gui.OSCommand, gui.Tr, gui.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gui.GitCommand = newGitCommand
|
||||
gui.State.Modes.Filtering.Path = ""
|
||||
return gui.Errors.ErrSwitchRepo
|
||||
}
|
||||
|
||||
// updateRecentRepoList registers the fact that we opened lazygit in this repo,
|
||||
// so that we can open the same repo via the 'recent repos' menu
|
||||
func (gui *Gui) updateRecentRepoList() error {
|
||||
|
Reference in New Issue
Block a user