1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-09 13:47:11 +02:00

more git ignore stuff in integration test

This commit is contained in:
Jesse Duffield 2022-12-28 17:15:59 +11:00
parent 31bdd27e88
commit 8a1c763942
19 changed files with 64 additions and 86 deletions

View File

@ -1,39 +0,0 @@
package file
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ExcludeGitignore = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Failed attempt at excluding and ignoring the .gitignore file",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
shell.CreateFile(".gitignore", "")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Contains(`?? .gitignore`).IsSelected(),
).
Press(keys.Files.IgnoreFile).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm()
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot exclude .gitignore")).Confirm()
}).
Press(keys.Files.IgnoreFile).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm()
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot ignore .gitignore")).Confirm()
})
t.FileSystem().FileContent(".gitignore", Equals(""))
t.FileSystem().FileContent(".git/info/exclude", DoesNotContain(".gitignore"))
},
})

View File

@ -0,0 +1,63 @@
package file
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var GitIgnore = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Verify that we can't ignore the .gitignore file, then ignore/exclude other files",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
shell.CreateFile(".gitignore", "")
shell.CreateFile("toExclude", "")
shell.CreateFile("toIgnore", "")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Contains(`?? .gitignore`).IsSelected(),
Contains(`?? toExclude`),
Contains(`?? toIgnore`),
).
Press(keys.Files.IgnoreFile).
// ensure we can't exclude the .gitignore file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm()
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot exclude .gitignore")).Confirm()
}).
Press(keys.Files.IgnoreFile).
// ensure we can't ignore the .gitignore file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm()
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot ignore .gitignore")).Confirm()
t.FileSystem().FileContent(".gitignore", Equals(""))
t.FileSystem().FileContent(".git/info/exclude", DoesNotContain(".gitignore"))
}).
SelectNextItem().
Press(keys.Files.IgnoreFile).
// exclude a file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm()
t.FileSystem().FileContent(".gitignore", Equals(""))
t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude"))
}).
SelectNextItem().
Press(keys.Files.IgnoreFile).
// ignore a file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm()
t.FileSystem().FileContent(".gitignore", Equals("toIgnore\n"))
t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude"))
})
},
})

View File

@ -54,7 +54,7 @@ var tests = []*components.IntegrationTest{
file.DirWithUntrackedFile,
file.DiscardChanges,
file.DiscardStagedChanges,
file.ExcludeGitignore,
file.GitIgnore,
interactive_rebase.AmendMerge,
interactive_rebase.One,
stash.Rename,

View File

@ -1 +0,0 @@
ref: refs/heads/master

View File

@ -1,10 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[user]
email = CI@example.com
name = CI

View File

@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.

View File

@ -1,9 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store
myfile1

View File

@ -1 +0,0 @@
0000000000000000000000000000000000000000 129cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 CI <CI@example.com> 1657012793 +1000 commit (initial): Initial commit

View File

@ -1 +0,0 @@
0000000000000000000000000000000000000000 129cdae0c4ccd050e8398bcb18b2ce1e4a5626f9 CI <CI@example.com> 1657012793 +1000 commit (initial): Initial commit

View File

@ -1 +0,0 @@
129cdae0c4ccd050e8398bcb18b2ce1e4a5626f9

View File

@ -1 +0,0 @@
test1

View File

@ -1 +0,0 @@
{"KeyEvents":[{"Timestamp":788,"Mod":0,"Key":256,"Ch":105},{"Timestamp":2342,"Mod":0,"Key":256,"Ch":101},{"Timestamp":3429,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":238,"Height":61}]}

View File

@ -1,15 +0,0 @@
#!/bin/sh
set -e
cd $1
git init
git config user.email "CI@example.com"
git config user.name "CI"
git commit --allow-empty -m "Initial commit"
echo test1 > myfile1

View File

@ -1,4 +0,0 @@
{
"description": "In this test a file is added to .git/info/exclude using the ignore or exclude menu",
"speed": 5
}