diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/git_commands/worktree.go | 20 | ||||
-rw-r--r-- | pkg/integration/components/view_driver.go | 2 | ||||
-rw-r--r-- | pkg/integration/tests/ui/switch_tab_from_menu.go | 4 |
3 files changed, 16 insertions, 10 deletions
diff --git a/pkg/commands/git_commands/worktree.go b/pkg/commands/git_commands/worktree.go index 460a8b7f9..cb108c46d 100644 --- a/pkg/commands/git_commands/worktree.go +++ b/pkg/commands/git_commands/worktree.go @@ -126,15 +126,22 @@ func GetCurrentRepoPath() string { return currentPath() } - // must be a worktree or bare repo + // either in a submodule, a worktree, or a bare repo worktreeGitPath, ok := WorktreeGitPath(pwd) if !ok { // fallback return currentPath() } - // now we just jump up three directories to get the repo name - return filepath.Dir(filepath.Dir(filepath.Dir(worktreeGitPath))) + // confirm whether the next directory up is the 'worktrees' directory + parent := filepath.Dir(worktreeGitPath) + if filepath.Base(parent) != "worktrees" { + // fallback + return currentPath() + } + + // now we just jump up two more directories to get the repo name + return filepath.Dir(filepath.Dir(parent)) } func GetCurrentRepoName() string { @@ -159,10 +166,7 @@ func linkedWortkreePaths() []string { // ensure the directory exists _, err := os.Stat(worktreePath) if err != nil { - if errors.Is(err, fs.ErrNotExist) { - return result - } - log.Fatalln(err.Error()) + return result } err = filepath.Walk(worktreePath, func(path string, info fs.FileInfo, err error) error { @@ -181,7 +185,7 @@ func linkedWortkreePaths() []string { return nil }) if err != nil { - log.Fatalln(err.Error()) + return result } return result diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go index d3216bb91..8c2624dec 100644 --- a/pkg/integration/components/view_driver.go +++ b/pkg/integration/components/view_driver.go @@ -330,7 +330,7 @@ func (self *ViewDriver) Focus() *ViewDriver { } windows := []window{ {name: "status", viewNames: []string{"status"}}, - {name: "files", viewNames: []string{"files", "submodules"}}, + {name: "files", viewNames: []string{"files", "worktrees", "submodules"}}, {name: "branches", viewNames: []string{"localBranches", "remotes", "tags"}}, {name: "commits", viewNames: []string{"commits", "reflogCommits"}}, {name: "stash", viewNames: []string{"stash"}}, diff --git a/pkg/integration/tests/ui/switch_tab_from_menu.go b/pkg/integration/tests/ui/switch_tab_from_menu.go index 26219f422..e74d76017 100644 --- a/pkg/integration/tests/ui/switch_tab_from_menu.go +++ b/pkg/integration/tests/ui/switch_tab_from_menu.go @@ -17,7 +17,9 @@ var SwitchTabFromMenu = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Universal.OptionMenuAlt1) t.ExpectPopup().Menu().Title(Equals("Keybindings")). - Select(Contains("Next tab")). + // Looping back around to the end to side-step the worktrees view which is + // only present on recent git versions + Select(Contains("Previous tab")). Confirm() t.Views().Submodules().IsFocused() |