1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-22 04:42:37 +03:00

Use git ls-files to list all file suggestions

This commit is contained in:
Stefan Haller
2025-11-20 08:41:44 +01:00
parent 9d24963ea0
commit 1c1676a5d9
3 changed files with 63 additions and 13 deletions

View File

@@ -563,3 +563,32 @@ func TestWorkingTreeResetHard(t *testing.T) {
})
}
}
func TestWorkingTreeCommands_AllRepoFiles(t *testing.T) {
scenarios := []struct {
name string
runner *oscommands.FakeCmdObjRunner
expected []string
}{
{
name: "no files",
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"ls-files", "-z"}, "", nil),
expected: []string{},
},
{
name: "two files",
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"ls-files", "-z"}, "dir/file1.txt\x00dir2/file2.go\x00", nil),
expected: []string{"dir/file1.txt", "dir2/file2.go"},
},
}
for _, s := range scenarios {
t.Run(s.name, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
result, err := instance.AllRepoFiles()
assert.NoError(t, err)
assert.Equal(t, s.expected, result)
})
}
}