Skip to content

Commit 267ef70

Browse files
committed
Add test showing problem with the display of renamed files
Renaming a file inside the same directory shows it with its full path in the tree view, which isn't what we want. We'll fix this in the next commit. Also adding a few other test cases for moving files; they show that the display of moved files in tree view isn't ideal. For example, moving file1 from top level into dir shows it as "R file1 → file1", which isn't distinguishable from renaming file1 inside dir. I suppose what we would like to have here is "R ../file1 → file1" or something, but I'll leave that for the future; here I only want to fix the regression that was introduced with the root item PR.
1 parent facc73a commit 267ef70

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package file
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var RenamedFiles = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Regression test for the display of renamed files in the file tree",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {
13+
},
14+
SetupRepo: func(shell *Shell) {
15+
shell.CreateDir("dir")
16+
shell.CreateDir("dir/nested")
17+
shell.CreateFileAndAdd("file1", "file1 content\n")
18+
shell.CreateFileAndAdd("dir/file2", "file2 content\n")
19+
shell.CreateFileAndAdd("dir/nested/file3", "file3 content\n")
20+
shell.Commit("initial commit")
21+
shell.RunCommand([]string{"git", "mv", "file1", "dir/file1"})
22+
shell.RunCommand([]string{"git", "mv", "dir/file2", "dir/file2-renamed"})
23+
shell.RunCommand([]string{"git", "mv", "dir/nested/file3", "file3"})
24+
},
25+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
26+
t.Views().Files().
27+
IsFocused().
28+
Lines(
29+
Equals("▼ /"),
30+
Equals(" ▼ dir"),
31+
Equals(" R file1 → file1"),
32+
Equals(" R dir/file2 → file2-renamed"), // don't want the 'dir/' prefix here
33+
Equals(" R dir/nested/file3 → file3"),
34+
)
35+
},
36+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ var tests = []*components.IntegrationTest{
195195
file.Gitignore,
196196
file.RememberCommitMessageAfterFail,
197197
file.RenameSimilarityThresholdChange,
198+
file.RenamedFiles,
198199
file.StageChildrenRangeSelect,
199200
file.StageDeletedRangeSelect,
200201
file.StageRangeSelect,

0 commit comments

Comments
 (0)