mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-29 22:48:24 +02:00
fix could-not-access error
This commit is contained in:
@@ -45,6 +45,15 @@ func (s *Shell) CreateFile(path string, content string) *Shell {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Shell) CreateDir(path string) *Shell {
|
||||
fullPath := filepath.Join(s.dir, path)
|
||||
if err := os.MkdirAll(fullPath, 0o755); err != nil {
|
||||
panic(fmt.Sprintf("error creating directory: %s\n%s", fullPath, err))
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Shell) UpdateFile(path string, content string) *Shell {
|
||||
fullPath := filepath.Join(s.dir, path)
|
||||
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
||||
|
||||
32
pkg/integration/tests/file/dir_with_untracked_file.go
Normal file
32
pkg/integration/tests/file/dir_with_untracked_file.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
// notably, we currently _don't_ actually see the untracked file in the diff. Not sure how to get around that.
|
||||
Description: "When selecting a directory that contains an untracked file, we should not get an error",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.UserConfig.Gui.ShowFileTree = true
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateDir("dir")
|
||||
shell.CreateFile("dir/file", "foo")
|
||||
shell.GitAddAll()
|
||||
shell.Commit("first commit")
|
||||
shell.CreateFile("dir/untracked", "bar")
|
||||
shell.UpdateFile("dir/file", "baz")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(1)
|
||||
|
||||
assert.MatchMainViewContent(NotContains("error: Could not access"))
|
||||
// we show baz because it's a modified file but we don't show bar because it's untracked
|
||||
// (though it would be cool if we could show that too)
|
||||
assert.MatchMainViewContent(Contains("baz"))
|
||||
},
|
||||
})
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/cherry_pick"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/commit"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/file"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
|
||||
)
|
||||
@@ -40,6 +41,7 @@ var tests = []*components.IntegrationTest{
|
||||
cherry_pick.CherryPickConflicts,
|
||||
custom_commands.FormPrompts,
|
||||
stash.Rename,
|
||||
file.DirWithUntrackedFile,
|
||||
}
|
||||
|
||||
func GetTests() []*components.IntegrationTest {
|
||||
|
||||
Reference in New Issue
Block a user