1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-04-11 19:29:52 +02:00
Files
lazygit/pkg/integration/tests/file/exclude_without_info_dir.go
cobyfrombrooklyn-bot 30154aa9c5 Fix #5302: Create .git/info directory before writing exclude file
When .git/info directory does not exist (can happen with bare clones
or manual deletion), the Exclude function failed with 'no such file
or directory'. Added os.MkdirAll to create the directory before
opening the exclude file.

Added integration test exclude_without_info_dir that removes .git/info
before attempting to exclude a file.
2026-03-08 16:23:39 +01:00

33 lines
1.0 KiB
Go

package file
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ExcludeWithoutInfoDir = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Exclude a file when .git/info directory does not exist",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
// Remove .git/info directory to reproduce #5302
shell.RunCommand([]string{"rm", "-rf", ".git/info"})
shell.CreateFile("toExclude", "")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Focus().
NavigateToLine(Contains("toExclude")).
Press(keys.Files.IgnoreFile).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Ignore or exclude file")).Select(Contains("Add to .git/info/exclude")).Confirm()
// Should succeed without error, creating .git/info/ directory automatically
t.FileSystem().FileContent(".git/info/exclude", Contains("/toExclude"))
})
},
})