diff --git a/test/integration/stagingTwo/expected/.git_keep/COMMIT_EDITMSG b/test/integration/stagingTwo/expected/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..e2129701f --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +file1 diff --git a/test/integration/stagingTwo/expected/.git_keep/FETCH_HEAD b/test/integration/stagingTwo/expected/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration/stagingTwo/expected/.git_keep/HEAD b/test/integration/stagingTwo/expected/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/stagingTwo/expected/.git_keep/config b/test/integration/stagingTwo/expected/.git_keep/config new file mode 100644 index 000000000..8ae104545 --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/config @@ -0,0 +1,10 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI diff --git a/test/integration/stagingTwo/expected/.git_keep/description b/test/integration/stagingTwo/expected/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/stagingTwo/expected/.git_keep/index b/test/integration/stagingTwo/expected/.git_keep/index new file mode 100644 index 000000000..04a93cbaf Binary files /dev/null and b/test/integration/stagingTwo/expected/.git_keep/index differ diff --git a/test/integration/stagingTwo/expected/.git_keep/info/exclude b/test/integration/stagingTwo/expected/.git_keep/info/exclude new file mode 100644 index 000000000..8e9f2071f --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/info/exclude @@ -0,0 +1,7 @@ +# 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 diff --git a/test/integration/stagingTwo/expected/.git_keep/logs/HEAD b/test/integration/stagingTwo/expected/.git_keep/logs/HEAD new file mode 100644 index 000000000..3e79e936b --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 f793cf3fd99464dbd3499093e95197229b771b11 CI 1642495374 +1100 commit (initial): file1 diff --git a/test/integration/stagingTwo/expected/.git_keep/logs/refs/heads/master b/test/integration/stagingTwo/expected/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..3e79e936b --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 f793cf3fd99464dbd3499093e95197229b771b11 CI 1642495374 +1100 commit (initial): file1 diff --git a/test/integration/stagingTwo/expected/.git_keep/objects/15/8e9a9c1a9627ea0ef4de8b00a503ed0f80a09e b/test/integration/stagingTwo/expected/.git_keep/objects/15/8e9a9c1a9627ea0ef4de8b00a503ed0f80a09e new file mode 100644 index 000000000..2c00719b0 Binary files /dev/null and b/test/integration/stagingTwo/expected/.git_keep/objects/15/8e9a9c1a9627ea0ef4de8b00a503ed0f80a09e differ diff --git a/test/integration/stagingTwo/expected/.git_keep/objects/7b/9c2149f16c706cea79b03234cb67fde7e9b68f b/test/integration/stagingTwo/expected/.git_keep/objects/7b/9c2149f16c706cea79b03234cb67fde7e9b68f new file mode 100644 index 000000000..611ed37a4 Binary files /dev/null and b/test/integration/stagingTwo/expected/.git_keep/objects/7b/9c2149f16c706cea79b03234cb67fde7e9b68f differ diff --git a/test/integration/stagingTwo/expected/.git_keep/objects/f7/93cf3fd99464dbd3499093e95197229b771b11 b/test/integration/stagingTwo/expected/.git_keep/objects/f7/93cf3fd99464dbd3499093e95197229b771b11 new file mode 100644 index 000000000..85ed192ae Binary files /dev/null and b/test/integration/stagingTwo/expected/.git_keep/objects/f7/93cf3fd99464dbd3499093e95197229b771b11 differ diff --git a/test/integration/stagingTwo/expected/.git_keep/refs/heads/master b/test/integration/stagingTwo/expected/.git_keep/refs/heads/master new file mode 100644 index 000000000..32457d556 --- /dev/null +++ b/test/integration/stagingTwo/expected/.git_keep/refs/heads/master @@ -0,0 +1 @@ +f793cf3fd99464dbd3499093e95197229b771b11 diff --git a/test/integration/stagingTwo/expected/one.txt b/test/integration/stagingTwo/expected/one.txt new file mode 100644 index 000000000..9b92aa365 --- /dev/null +++ b/test/integration/stagingTwo/expected/one.txt @@ -0,0 +1,64 @@ +package oscommands + +import ( + "github.com/jesseduffield/lazygit/pkg/common" + "github.com/jesseduffield/lazygit/pkg/utils" +) + +// NewDummyOSCommand creates a new dummy OSCommand for testing +func NewDummyOSCommand() *OSCommand { + osCmd := NewOSCommand(utils.NewDummyCommon(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog())) + + return osCmd +} + +type OSCommandDeps struct { + Common *common.Common + Platform *Platform + GetenvFn func(string) string + RemoveFileFn func(string) error + Cmd *CmdObjBuilder +} + +func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand { + common := deps.Common + if common == nil { + common = utils.NewDummyCommon() + } + + platform := deps.Platform + if platform == nil { + platform = dummyPlatform + } + + return &OSCommand{ + Common: common, + Platform: platform, + getenvFn: deps.GetenvFn, + removeFileFn: deps.RemoveFileFn, + guiIO: NewNullGuiIO(utils.NewDummyLog()), + Cmd: deps.Cmd, + } +} + +func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder { + return &CmdObjBuilder{ + runner: runner, + platform: dummyPlatform, + } +} + +var dummyPlatform = &Platform{ + OS: "darwin", + Shell: "bash", + ShellArg: "-c", + OpenCommand: "open {{filename}}", + OpenLinkCommand: "open {{link}}", +} + +func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand { + osCommand := NewOSCommand(utils.NewDummyCommon(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog())) + osCommand.Cmd = NewDummyCmdObjBuilder(runner) + + return osCommand +} diff --git a/test/integration/stagingTwo/files/one.txt b/test/integration/stagingTwo/files/one.txt new file mode 100644 index 000000000..158e9a9c1 --- /dev/null +++ b/test/integration/stagingTwo/files/one.txt @@ -0,0 +1,63 @@ +package oscommands + +import ( + "github.com/jesseduffield/lazygit/pkg/common" + "github.com/jesseduffield/lazygit/pkg/utils" +) + +// NewDummyOSCommand creates a new dummy OSCommand for testing +func NewDummyOSCommand() *OSCommand { + osCmd := NewOSCommand(utils.NewDummyCommon(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog())) + + return osCmd +} + +type OSCommandDeps struct { + Common *common.Common + Platform *Platform + GetenvFn func(string) string + RemoveFileFn func(string) error + Cmd *CmdObjBuilder +} + +func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand { + common := deps.Common + if common == nil { + common = utils.NewDummyCommon() + } + + platform := deps.Platform + if platform == nil { + platform = dummyPlatform + } + + return &OSCommand{ + Common: common, + Platform: platform, + getenvFn: deps.GetenvFn, + removeFileFn: deps.RemoveFileFn, + guiIO: NewNullGuiIO(utils.NewDummyLog()), + } +} + +func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder { + return &CmdObjBuilder{ + runner: runner, + platform: dummyPlatform, + } +} + +var dummyPlatform = &Platform{ + OS: "darwin", + Shell: "bash", + ShellArg: "-c", + OpenCommand: "open {{filename}}", + OpenLinkCommand: "open {{link}}", +} + +func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand { + osCommand := NewOSCommand(utils.NewDummyCommon(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog())) + osCommand.Cmd = NewDummyCmdObjBuilder(runner) + + return osCommand +} diff --git a/test/integration/stagingTwo/files/one_new.txt b/test/integration/stagingTwo/files/one_new.txt new file mode 100644 index 000000000..c3323cfc9 --- /dev/null +++ b/test/integration/stagingTwo/files/one_new.txt @@ -0,0 +1,67 @@ +package oscommands + +import ( + "github.com/jesseduffield/lazygit/pkg/common" + "github.com/jesseduffield/lazygit/pkg/utils" +) + +// NewDummyOSCommand creates a new dummy OSCommand for testing +func NewDummyOSCommand() *OSCommand { + osCmd := NewOSCommand(utils.NewDummyCommon(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog())) + + return osCmd +} + +type OSCommandDeps struct { + Common *common.Common + Platform *Platform + GetenvFn func(string) string + RemoveFileFn func(string) error + Cmd *CmdObjBuilder +} + +func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand { + if deps.Cmd == nil { + panic("WHAT") + } + common := deps.Common + if common == nil { + common = utils.NewDummyCommon() + } + + platform := deps.Platform + if platform == nil { + platform = dummyPlatform + } + + return &OSCommand{ + Common: common, + Platform: platform, + getenvFn: deps.GetenvFn, + removeFileFn: deps.RemoveFileFn, + guiIO: NewNullGuiIO(utils.NewDummyLog()), + Cmd: deps.Cmd, + } +} + +func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder { + return &CmdObjBuilder{ + runner: runner, + platform: dummyPlatform, + } +} + +var dummyPlatform = &Platform{ + OS: "darwin", + Shell: "bash", + ShellArg: "-c", + OpenCommand: "open {{filename}}", + OpenLinkCommand: "open {{link}}", +} + +func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand { + osCommand := NewOSCommand(utils.NewDummyCommon(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog())) + osCommand.Cmd = NewDummyCmdObjBuilder(runner) + + return osCommand +} diff --git a/test/integration/stagingTwo/recording.json b/test/integration/stagingTwo/recording.json new file mode 100644 index 000000000..c089a5783 --- /dev/null +++ b/test/integration/stagingTwo/recording.json @@ -0,0 +1 @@ +{"KeyEvents":[{"Timestamp":843,"Mod":0,"Key":13,"Ch":13},{"Timestamp":1122,"Mod":0,"Key":256,"Ch":118},{"Timestamp":1266,"Mod":0,"Key":258,"Ch":0},{"Timestamp":1386,"Mod":0,"Key":258,"Ch":0},{"Timestamp":1602,"Mod":0,"Key":256,"Ch":100},{"Timestamp":1851,"Mod":0,"Key":13,"Ch":13},{"Timestamp":2520,"Mod":0,"Key":27,"Ch":0},{"Timestamp":3195,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/stagingTwo/setup.sh b/test/integration/stagingTwo/setup.sh new file mode 100644 index 000000000..7cfacd06f --- /dev/null +++ b/test/integration/stagingTwo/setup.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +cd $1 + +git init + +git config user.email "CI@example.com" +git config user.name "CI" + +cp ../files/one.txt one.txt +git add . +git commit -am file1 + +cp ../files/one_new.txt one.txt diff --git a/test/integration/stagingTwo/test.json b/test/integration/stagingTwo/test.json new file mode 100644 index 000000000..023d766c4 --- /dev/null +++ b/test/integration/stagingTwo/test.json @@ -0,0 +1,4 @@ +{ + "description": "Some more line-by-line staging", + "speed": 20 +}