mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
Fix tests
Going and fixing up some submodule tests which were broken by bad assumptions with worktree code
This commit is contained in:
@ -126,15 +126,22 @@ func GetCurrentRepoPath() string {
|
|||||||
return currentPath()
|
return currentPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
// must be a worktree or bare repo
|
// either in a submodule, a worktree, or a bare repo
|
||||||
worktreeGitPath, ok := WorktreeGitPath(pwd)
|
worktreeGitPath, ok := WorktreeGitPath(pwd)
|
||||||
if !ok {
|
if !ok {
|
||||||
// fallback
|
// fallback
|
||||||
return currentPath()
|
return currentPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we just jump up three directories to get the repo name
|
// confirm whether the next directory up is the 'worktrees' directory
|
||||||
return filepath.Dir(filepath.Dir(filepath.Dir(worktreeGitPath)))
|
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 {
|
func GetCurrentRepoName() string {
|
||||||
@ -159,11 +166,8 @@ func linkedWortkreePaths() []string {
|
|||||||
// ensure the directory exists
|
// ensure the directory exists
|
||||||
_, err := os.Stat(worktreePath)
|
_, err := os.Stat(worktreePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, fs.ErrNotExist) {
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
log.Fatalln(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
err = filepath.Walk(worktreePath, func(path string, info fs.FileInfo, err error) error {
|
err = filepath.Walk(worktreePath, func(path string, info fs.FileInfo, err error) error {
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
@ -181,7 +185,7 @@ func linkedWortkreePaths() []string {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err.Error())
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -330,7 +330,7 @@ func (self *ViewDriver) Focus() *ViewDriver {
|
|||||||
}
|
}
|
||||||
windows := []window{
|
windows := []window{
|
||||||
{name: "status", viewNames: []string{"status"}},
|
{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: "branches", viewNames: []string{"localBranches", "remotes", "tags"}},
|
||||||
{name: "commits", viewNames: []string{"commits", "reflogCommits"}},
|
{name: "commits", viewNames: []string{"commits", "reflogCommits"}},
|
||||||
{name: "stash", viewNames: []string{"stash"}},
|
{name: "stash", viewNames: []string{"stash"}},
|
||||||
|
@ -17,7 +17,9 @@ var SwitchTabFromMenu = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Press(keys.Universal.OptionMenuAlt1)
|
Press(keys.Universal.OptionMenuAlt1)
|
||||||
|
|
||||||
t.ExpectPopup().Menu().Title(Equals("Keybindings")).
|
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()
|
Confirm()
|
||||||
|
|
||||||
t.Views().Submodules().IsFocused()
|
t.Views().Submodules().IsFocused()
|
||||||
|
Reference in New Issue
Block a user