mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-03 13:21:56 +02:00
Show loader when switching worktrees
This commit is contained in:
parent
81a9133261
commit
b5ff55e538
@ -8,6 +8,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/jesseduffield/generics/slices"
|
"github.com/jesseduffield/generics/slices"
|
||||||
|
"github.com/jesseduffield/gocui"
|
||||||
appTypes "github.com/jesseduffield/lazygit/pkg/app/types"
|
appTypes "github.com/jesseduffield/lazygit/pkg/app/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
@ -143,40 +144,42 @@ func (self *ReposHelper) DispatchSwitchToRepo(path string, reuse bool, contextKe
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *ReposHelper) DispatchSwitchTo(path string, reuse bool, errMsg string, contextKey types.ContextKey) error {
|
func (self *ReposHelper) DispatchSwitchTo(path string, reuse bool, errMsg string, contextKey types.ContextKey) error {
|
||||||
env.UnsetGitDirEnvs()
|
return self.c.WithWaitingStatus(self.c.Tr.Switching, func(gocui.Task) error {
|
||||||
originalPath, err := os.Getwd()
|
env.UnsetGitDirEnvs()
|
||||||
if err != nil {
|
originalPath, err := os.Getwd()
|
||||||
return nil
|
if err != nil {
|
||||||
}
|
return nil
|
||||||
|
|
||||||
self.c.LogCommand(fmt.Sprintf("Changing directory to %s", path), false)
|
|
||||||
|
|
||||||
if err := os.Chdir(path); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return self.c.ErrorMsg(errMsg)
|
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := commands.VerifyInGitRepo(self.c.OS()); err != nil {
|
self.c.LogCommand(fmt.Sprintf("Changing directory to %s", path), false)
|
||||||
if err := os.Chdir(originalPath); err != nil {
|
|
||||||
|
if err := os.Chdir(path); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return self.c.ErrorMsg(errMsg)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
if err := commands.VerifyInGitRepo(self.c.OS()); err != nil {
|
||||||
}
|
if err := os.Chdir(originalPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := self.recordDirectoryHelper.RecordCurrentDirectory(); err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// these two mutexes are used by our background goroutines (triggered via `self.goEvery`. We don't want to
|
if err := self.recordDirectoryHelper.RecordCurrentDirectory(); err != nil {
|
||||||
// switch to a repo while one of these goroutines is in the process of updating something
|
return err
|
||||||
self.c.Mutexes().SyncMutex.Lock()
|
}
|
||||||
defer self.c.Mutexes().SyncMutex.Unlock()
|
|
||||||
|
|
||||||
self.c.Mutexes().RefreshingFilesMutex.Lock()
|
// these two mutexes are used by our background goroutines (triggered via `self.goEvery`. We don't want to
|
||||||
defer self.c.Mutexes().RefreshingFilesMutex.Unlock()
|
// switch to a repo while one of these goroutines is in the process of updating something
|
||||||
|
self.c.Mutexes().SyncMutex.Lock()
|
||||||
|
defer self.c.Mutexes().SyncMutex.Unlock()
|
||||||
|
|
||||||
return self.onNewRepo(appTypes.StartArgs{}, reuse, contextKey)
|
self.c.Mutexes().RefreshingFilesMutex.Lock()
|
||||||
|
defer self.c.Mutexes().RefreshingFilesMutex.Unlock()
|
||||||
|
|
||||||
|
return self.onNewRepo(appTypes.StartArgs{}, reuse, contextKey)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -544,6 +544,7 @@ type TranslationSet struct {
|
|||||||
ExitSearchMode string
|
ExitSearchMode string
|
||||||
ExitTextFilterMode string
|
ExitTextFilterMode string
|
||||||
SwitchToWorktree string
|
SwitchToWorktree string
|
||||||
|
Switching string
|
||||||
RemoveWorktree string
|
RemoveWorktree string
|
||||||
RemoveWorktreeTitle string
|
RemoveWorktreeTitle string
|
||||||
DetachWorktree string
|
DetachWorktree string
|
||||||
@ -1278,6 +1279,7 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
WorktreesTitle: "Worktrees",
|
WorktreesTitle: "Worktrees",
|
||||||
WorktreeTitle: "Worktree",
|
WorktreeTitle: "Worktree",
|
||||||
SwitchToWorktree: "Switch to worktree",
|
SwitchToWorktree: "Switch to worktree",
|
||||||
|
Switching: "Switching",
|
||||||
RemoveWorktree: "Remove worktree",
|
RemoveWorktree: "Remove worktree",
|
||||||
RemoveWorktreeTitle: "Remove worktree",
|
RemoveWorktreeTitle: "Remove worktree",
|
||||||
RemoveWorktreePrompt: "Are you sure you want to remove worktree '{{.worktreeName}}'?",
|
RemoveWorktreePrompt: "Are you sure you want to remove worktree '{{.worktreeName}}'?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user