mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
Add test that shows problems with git-ignoring files with special characters
For #, !, [, and ], the problem is that it doesn't ignore the file because the special characters need to be quoted. For *, the problem is that it ignores too much (it also hides the abc_def file because the * is treated as a glob).
This commit is contained in:
parent
d70a405169
commit
41f89d86f0
2 changed files with 88 additions and 0 deletions
87
pkg/integration/tests/file/gitignore_special_characters.go
Normal file
87
pkg/integration/tests/file/gitignore_special_characters.go
Normal file
|
@ -0,0 +1,87 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var GitignoreSpecialCharacters = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Ignore files with special characters in their names",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFile(".gitignore", "")
|
||||
shell.CreateFile("#file", "")
|
||||
shell.CreateFile("file#abc", "")
|
||||
shell.CreateFile("!file", "")
|
||||
shell.CreateFile("file!abc", "")
|
||||
shell.CreateFile("abc*def", "")
|
||||
shell.CreateFile("abc_def", "")
|
||||
shell.CreateFile("file[x]", "")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
excludeFile := func(fileName string) {
|
||||
t.Views().Files().
|
||||
NavigateToLine(Contains(fileName)).
|
||||
Press(keys.Files.IgnoreFile)
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Ignore or exclude file")).
|
||||
Select(Contains("Add to .gitignore")).
|
||||
Confirm()
|
||||
}
|
||||
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
Lines(
|
||||
Equals("▼ /"),
|
||||
Equals(" ?? !file"),
|
||||
Equals(" ?? #file"),
|
||||
Equals(" ?? .gitignore"),
|
||||
Equals(" ?? abc*def"),
|
||||
Equals(" ?? abc_def"),
|
||||
Equals(" ?? file!abc"),
|
||||
Equals(" ?? file#abc"),
|
||||
Equals(" ?? file[x]"),
|
||||
)
|
||||
|
||||
excludeFile("#file")
|
||||
excludeFile("file#abc")
|
||||
excludeFile("!file")
|
||||
excludeFile("file!abc")
|
||||
excludeFile("abc*def")
|
||||
excludeFile("file[x]")
|
||||
|
||||
t.Views().Files().
|
||||
/* EXPECTED:
|
||||
Lines(
|
||||
Equals("▼ /"),
|
||||
Equals(" ?? .gitignore"),
|
||||
Equals(" ?? abc_def"),
|
||||
)
|
||||
ACTUAL:
|
||||
As you can see, it did ignore the 'file!abc' and 'file#abc' files
|
||||
correctly. Those don't need to be quoted because # and ! are only
|
||||
special at the beginning.
|
||||
|
||||
Most of the other files are not ignored properly because their
|
||||
special characters need to be escaped. For * it's the other way
|
||||
round: while it does hide 'abc*def', it also hides 'abc_def',
|
||||
which we don't want.
|
||||
*/
|
||||
Lines(
|
||||
Equals("▼ /"),
|
||||
Equals(" ?? !file"),
|
||||
Equals(" ?? #file"),
|
||||
Equals(" ?? .gitignore"),
|
||||
Equals(" ?? file[x]"),
|
||||
)
|
||||
|
||||
/* EXPECTED:
|
||||
t.FileSystem().FileContent(".gitignore", Equals("\\#file\nfile#abc\n\\!file\nfile!abc\nabc\\*def\nfile\\[x\\]\n"))
|
||||
ACTUAL: */
|
||||
t.FileSystem().FileContent(".gitignore", Equals("#file\nfile#abc\n!file\nfile!abc\nabc*def\nfile[x]\n"))
|
||||
},
|
||||
})
|
|
@ -197,6 +197,7 @@ var tests = []*components.IntegrationTest{
|
|||
file.DiscardVariousChanges,
|
||||
file.DiscardVariousChangesRangeSelect,
|
||||
file.Gitignore,
|
||||
file.GitignoreSpecialCharacters,
|
||||
file.RememberCommitMessageAfterFail,
|
||||
file.RenameSimilarityThresholdChange,
|
||||
file.RenamedFiles,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue