diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-10 16:01:46 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-11 17:07:49 +1000 |
commit | bb918b579a3073d786fda83a2bc11c602e442aa0 (patch) | |
tree | fe126f12a88db9a9e119d0b172c0902bc0f49244 /pkg | |
parent | e145090046e1693e2100cb0a0ab40a271705f4b0 (diff) |
start adding support for logging of commands
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/commits.go | 6 | ||||
-rw-r--r-- | pkg/commands/dummies.go | 1 | ||||
-rw-r--r-- | pkg/commands/files.go | 386 | ||||
-rw-r--r-- | pkg/commands/files_test.go | 381 | ||||
-rw-r--r-- | pkg/commands/git.go | 10 | ||||
-rw-r--r-- | pkg/commands/oscommands/exec_live_default.go | 1 | ||||
-rw-r--r-- | pkg/commands/oscommands/os.go | 128 | ||||
-rw-r--r-- | pkg/commands/patch_rebases.go | 2 | ||||
-rw-r--r-- | pkg/commands/stash_entries.go | 2 | ||||
-rw-r--r-- | pkg/gui/arrangement.go | 2 | ||||
-rw-r--r-- | pkg/gui/commit_message_panel.go | 5 | ||||
-rw-r--r-- | pkg/gui/discard_changes_menu_panel.go | 9 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 55 | ||||
-rw-r--r-- | pkg/gui/git_flow.go | 2 | ||||
-rw-r--r-- | pkg/gui/gui.go | 34 | ||||
-rw-r--r-- | pkg/gui/patch_options_panel.go | 22 | ||||
-rw-r--r-- | pkg/gui/rebase_options_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/staging_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/submodules_panel.go | 26 |
20 files changed, 595 insertions, 487 deletions
diff --git a/pkg/commands/commits.go b/pkg/commands/commits.go index 3582131a6..df1a8a2c7 100644 --- a/pkg/commands/commits.go +++ b/pkg/commands/commits.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "os/exec" "strings" "github.com/jesseduffield/lazygit/pkg/commands/models" @@ -53,11 +52,6 @@ func (c *GitCommand) AmendHead() error { return c.OSCommand.RunCommand(c.AmendHeadCmdStr()) } -// PrepareCommitAmendHeadSubProcess prepares a subprocess for `git commit --amend --allow-empty` -func (c *GitCommand) PrepareCommitAmendHeadSubProcess() *exec.Cmd { - return c.OSCommand.ShellCommandFromString(c.AmendHeadCmdStr()) -} - func (c *GitCommand) AmendHeadCmdStr() string { return "git commit --amend --no-edit --allow-empty" } diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go index 933959fe7..6feb908e3 100644 --- a/pkg/commands/dummies.go +++ b/pkg/commands/dummies.go @@ -20,6 +20,5 @@ func NewDummyGitCommandWithOSCommand(osCommand *oscommands.OSCommand) *GitComman Tr: i18n.NewTranslationSet(utils.NewDummyLog()), Config: config.NewDummyAppConfig(), getGitConfigValue: func(string) (string, error) { return "", nil }, - removeFile: func(string) error { return nil }, } } diff --git a/pkg/commands/files.go b/pkg/commands/files.go index 9b4895710..4071c8c76 100644 --- a/pkg/commands/files.go +++ b/pkg/commands/files.go @@ -2,20 +2,14 @@ package commands import ( "fmt" - "io/ioutil" "os" - "os/exec" "path/filepath" - "testing" "time" "github.com/go-errors/errors" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/filetree" - "github.com/jesseduffield/lazygit/pkg/secureexec" - "github.com/jesseduffield/lazygit/pkg/test" "github.com/jesseduffield/lazygit/pkg/utils" - "github.com/stretchr/testify/assert" ) // CatFile obtains the content of a file @@ -145,7 +139,7 @@ func (c *GitCommand) DiscardAllFileChanges(file *models.File) error { } if file.Added { - return c.removeFile(file.Name) + return c.OSCommand.RemoveFile(file.Name) } return c.DiscardUnstagedFileChanges(file) } @@ -346,381 +340,3 @@ func (c *GitCommand) EditFileCmdStr(filename string) (string, error) { return fmt.Sprintf("%s %s", editor, c.OSCommand.Quote(filename)), nil } - -func TestGitCommandApplyPatch(t *testing.T) { - type scenario struct { - testName string - command func(string, ...string) *exec.Cmd - test func(error) - } - - scenarios := []scenario{ - { - "valid case", - func(cmd string, args ...string) *exec.Cmd { - assert.Equal(t, "git", cmd) - assert.EqualValues(t, []string{"apply", "--cached"}, args[0:2]) - filename := args[2] - content, err := ioutil.ReadFile(filename) - assert.NoError(t, err) - - assert.Equal(t, "test", string(content)) - - return secureexec.Command("echo", "done") - }, - func(err error) { - assert.NoError(t, err) - }, - }, - { - "command returns error", - func(cmd string, args ...string) *exec.Cmd { - assert.Equal(t, "git", cmd) - assert.EqualValues(t, []string{"apply", "--cached"}, args[0:2]) - filename := args[2] - // TODO: Ideally we want to mock out OSCommand here so that we're not - // double handling testing it's CreateTempFile functionality, - // but it is going to take a bit of work to make a proper mock for it - // so I'm leaving it for another PR - content, err := ioutil.ReadFile(filename) - assert.NoError(t, err) - - assert.Equal(t, "test", string(content)) - - return secureexec.Command("test") - }, - func(err error) { - assert.Error(t, err) - }, - }, - } - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd := NewDummyGitCommand() - gitCmd.OSCommand.Command = s.command - s.test(gitCmd.ApplyPatch("test", "cached")) - }) - } -} - -// TestGitCommandDiscardOldFileChanges is a function. -func TestGitCommandDiscardOldFileChanges(t *testing.T) { - type scenario struct { - testName string - getGitConfigValue func(string) (string, error) - commits []*models.Commit - commitIndex int - fileName string - command func(string, ...string) *exec.Cmd - test func(error) - } - - scenarios := []scenario{ - { - "returns error when index outside of range of commits", - func(string) (string, error) { - return "", nil - }, - []*models.Commit{}, - 0, - "test999.txt", - nil, - func(err error) { - assert.Error(t, err) - }, - }, - { - "returns error when using gpg", - func(string) (string, error) { - return "true", nil - }, - []*models.Commit{{Name: "commit", Sha: "123456"}}, - 0, - "test999.txt", - nil, - func(err error) { - assert.Error(t, err) - }, - }, - { - "checks out file if it already existed", - func(string) (string, error) { - return "", nil - }, - []*models.Commit{ - {Name: "commit", Sha: "123456"}, - {Name: "commit2", Sha: "abcdef"}, - }, - 0, - "test999.txt", - test.CreateMockCommand(t, []*test.CommandSwapper{ - { - Expect: "git rebase --interactive --autostash --keep-empty abcdef", - Replace: "echo", - }, - { - Expect: "git cat-file -e HEAD^:test999.txt", - Replace: "echo", - }, - { - Expect: "git checkout HEAD^ test999.txt", - Replace: "echo", - }, - { - Expect: "git commit --amend --no-edit --allow-empty", - Replace: "echo", - }, - { - Expect: "git rebase --continue", - Replace: "echo", - }, - }), - func(err error) { - assert.NoError(t, err) - }, - }, - // test for when the file was created within the commit requires a refactor to support proper mocks - // currently we'd need to mock out the os.Remove function and that's gonna introduce tech debt - } - - gitCmd := NewDummyGitCommand() - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd.OSCommand.Command = s.command - gitCmd.getGitConfigValue = s.getGitConfigValue - s.test(gitCmd.DiscardOldFileChanges(s.commits, s.commitIndex, s.fileName)) - }) - } -} - -// TestGitCommandDiscardUnstagedFileChanges is a function. -func TestGitCommandDiscardUnstagedFileChanges(t *testing.T) { - type scenario struct { - testName string - file *models.File - command func(string, ...string) *exec.Cmd - test func(error) - } - - scenarios := []scenario{ - { - "valid case", - &models.File{Name: "test.txt"}, - test.CreateMockCommand(t, []*test.CommandSwapper{ - { - Expect: `git checkout -- "test.txt"`, - Replace: "echo", - }, - }), - func(err error) { - assert.NoError(t, err) - }, - }, - } - - gitCmd := NewDummyGitCommand() - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd.OSCommand.Command = s.command - s.test(gitCmd.DiscardUnstagedFileChanges(s.file)) - }) - } -} - -// TestGitCommandDiscardAnyUnstagedFileChanges is a function. -func TestGitCommandDiscardAnyUnstagedFileChanges(t *testing.T) { - type scenario struct { - testName string - command func(string, ...string) *exec.Cmd - test func(error) - } - - scenarios := []scenario{ - { - "valid case", - test.CreateMockCommand(t, []*test.CommandSwapper{ - { - Expect: `git checkout -- .`, - Replace: "echo", - }, - }), - func(err error) { - assert.NoError(t, err) - }, - }, - } - - gitCmd := NewDummyGitCommand() - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd.OSCommand.Command = s.command - s.test(gitCmd.DiscardAnyUnstagedFileChanges()) - }) - } -} - -// TestGitCommandRemoveUntrackedFiles is a function. -func TestGitCommandRemoveUntrackedFiles(t *testing.T) { - type scenario struct { - testName string - command func(string, ...string) *exec.Cmd - test func(error) - } - - scenarios := []scenario{ - { - "valid case", - test.CreateMockCommand(t, []*test.CommandSwapper{ - { - Expect: `git clean -fd`, - Replace: "echo", - }, - }), - func(err error) { - assert.NoError(t, err) - }, - }, - } - - gitCmd := NewDummyGitCommand() - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd.OSCommand.Command = s.command - s.test(gitCmd.RemoveUntrackedFiles()) - }) - } -} - -// TestEditFileCmdStr is a function. -func TestEditFileCmdStr(t *testing.T) { - type scenario struct { - filename string - command func(string, ...string) *exec.Cmd - getenv func(string) string - getGitConfigValue func(string) (string, error) - test func(string, error) - } - - scenarios := []scenario{ - { - "test", - func(name string, arg ...string) *exec.Cmd { - return secureexec.Command("exit", "1") - }, - func(env string) string { - return "" - }, - func(cf string) (string, error) { - return "", nil - }, - func(cmdStr string, err error) { - assert.EqualError(t, err, "No editor defined in $GIT_EDITOR, $VISUAL, $EDITOR, or git config") - }, - }, - { - "test", - func(name string, arg ...string) *exec.Cmd { - assert.Equal(t, "which", name) - return secureexec.Command("exit", "1") - }, - func(env string) string { - return "" - }, - func(cf string) (string, error) { - return "nano", nil - }, - func(cmdStr string, err error) { - assert.NoError(t, err) - assert.Equal(t, "nano \"test\"", cmdStr) - }, - }, - { - "test", - func(name string, arg ...string) *exec.Cmd { - assert.Equal(t, "which", name) - return secureexec.Command("exit", "1") - }, - func(env string) string { - if env == "VISUAL" { - return "nano" - } - - return "" - }, - func(cf string) (string, error) { - return "", nil - }, - func(cmdStr string, err error) { - assert.NoError(t, err) - }, - }, - { - "test", - func(name string, arg ...string) *exec.Cmd { - assert.Equal(t, "which", name) - return secureexec.Command("exit", "1") - }, - func(env string) string { - if env == "EDITOR" { - return "emacs" - } - - return "" - }, - func(cf string) (string, error) { - return "", nil - }, - func(cmdStr string, err error) { - assert.NoError(t, err) - assert.Equal(t, "emacs \"test\"", cmdStr) - }, - }, - { - "test", - func(name string, arg ...string) *exec.Cmd { - assert.Equal(t, "which", name) - return secureexec.Command("echo") - }, - func(env string) string { - return "" - }, - func(cf string) (string, error) { - return "", nil - }, - func(cmdStr string, err error) { - assert.NoError(t, err) - assert.Equal(t, "vi \"test\"", cmdStr) - }, - }, - { - "file/with space", - func(name string, args ...string) *exec.Cmd { - assert.Equal(t, "which", name) - return secureexec.Command("echo") - }, - func(env string) string { - return "" - }, - func(cf string) (string, error) { - return "", nil - }, - func(cmdStr string, err error) { - assert.NoError(t, err) - assert.Equal(t, "vi \"file/with space\"", cmdStr) - }, - }, - } - - for _, s := range scenarios { - gitCmd := NewDummyGitCommand() - gitCmd.OSCommand.Command = s.command - gitCmd.OSCommand.Getenv = s.getenv - gitCmd.getGitConfigValue = s.getGitConfigValue - s.test(gitCmd.EditFileCmdStr(s.filename)) - } -} diff --git a/pkg/commands/files_test.go b/pkg/commands/files_test.go index 62aa388cb..20c18a9a0 100644 --- a/pkg/commands/files_test.go +++ b/pkg/commands/files_test.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "io/ioutil" "os/exec" "runtime" "testing" @@ -323,7 +324,7 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { var cmdsCalled *[][]string gitCmd := NewDummyGitCommand() gitCmd.OSCommand.Command, cmdsCalled = s.command() - gitCmd.removeFile = s.removeFile + gitCmd.OSCommand.SetRemoveFile(s.removeFile) s.test(cmdsCalled, gitCmd.DiscardAllFileChanges(s.file)) }) } @@ -465,3 +466,381 @@ func TestGitCommandCheckoutFile(t *testing.T) { }) } } + +func TestGitCommandApplyPatch(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(error) + } + + scenarios := []scenario{ + { + "valid case", + func(cmd string, args ...string) *exec.Cmd { + assert.Equal(t, "git", cmd) + assert.EqualValues(t, []string{"apply", "--cached"}, args[0:2]) + filename := args[2] + content, err := ioutil.ReadFile(filename) + assert.NoError(t, err) + + assert.Equal(t, "test", string(content)) + + return secureexec.Command("echo", "done") + }, + func(err error) { + assert.NoError(t, err) + }, + }, + { + "command returns error", + func(cmd string, args ...string) *exec.Cmd { + assert.Equal(t, "git", cmd) + assert.EqualValues(t, []string{"apply", "--cached"}, args[0:2]) + filename := args[2] + // TODO: Ideally we want to mock out OSCommand here so that we're not + // double handling testing it's CreateTempFile functionality, + // but it is going to take a bit of work to make a proper mock for it + // so I'm leaving it for another PR + content, err := ioutil.ReadFile(filename) + assert.NoError(t, err) + + assert.Equal(t, "test", string(content)) + + return secureexec.Command("test") + }, + func(err error) { + assert.Error(t, err) + }, + }, + } + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd := NewDummyGitCommand() + gitCmd.OSCommand.Command = s.command + s.test(gitCmd.ApplyPatch("test", "cached")) + }) + } +} + +// TestGitCommandDiscardOldFileChanges is a function. +func TestGitCommandDiscardOldFileChanges(t *testing.T) { + type scenario struct { + testName string + getGitConfigValue func(string) (string, error) + commits []*models.Commit + commitIndex int + fileName string + command func(string, ...string) *exec.Cmd + test func(error) + } + + scenarios := []scenario{ + { + "returns error when index outside of range of commits", + func(string) (string, error) { + return "", nil + }, + []*models.Commit{}, + 0, + "test999.txt", + nil, + func(err error) { + assert.Error(t, err) + }, + }, + { + "returns error when using gpg", + func(string) (string, error) { + return "true", nil + }, + []*models.Commit{{Name: "commit", Sha: "123456"}}, + 0, + "test999.txt", + nil, + func(err error) { + assert.Error(t, err) + }, + }, + { + "checks out file if it already existed", + func(string) (string, error) { + return "", nil + }, + []*models.Commit{ + {Name: "commit", Sha: "123456"}, + {Name: "commit2", Sha: "abcdef"}, + }, + 0, + "test999.txt", + test.CreateMockCommand(t, []*test.CommandSwapper{ + { + Expect: "git rebase --interactive --autostash --keep-empty abcdef", + Replace: "echo", + }, + { + Expect: "git cat-file -e HEAD^:test999.txt", + Replace: "echo", + }, + { + Expect: "git checkout HEAD^ test999.txt", + Replace: "echo", + }, + { + Expect: "git commit --amend --no-edit --allow-empty", + Replace: "echo", + }, + { + Expect: "git rebase --continue", + Replace: "echo", + }, + }), + func(err error) { + assert.NoError(t, err) + }, + }, + // test for when the file was created within the commit requires a refactor to support proper mocks + // currently we'd need to mock out the os.Remove function and that's gonna introduce tech debt + } + + gitCmd := NewDummyGitCommand() + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd.OSCommand.Command = s.command + gitCmd.getGitConfigValue = s.getGitConfigValue + s.test(gitCmd.DiscardOldFileChanges(s.commits, s.commitIndex, s.fileName)) + }) + } +} + +// TestGitCommandDiscardUnstagedFileChanges is a function. +func TestGitCommandDiscardUnstagedFileChanges(t *testing.T) { + type scenario struct { + testName string + file *models.File + command func(string, ...string) *exec.Cmd + test func(error) + } + + scenarios := []scenario{ + { + "valid case", + &models.File{Name: "test.txt"}, + test.CreateMockCommand(t, []*test.CommandSwapper{ + { + Expect: `git checkout -- "test.txt"`, + Replace: "echo", + }, + }), + func(err error) { + assert.NoError(t, err) + }, + }, + } + + gitCmd := NewDummyGitCommand() + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd.OSCommand.Command = s.command + s.test(gitCmd.DiscardUnstagedFileChanges(s.file)) + }) + } +} + +// TestGitCommandDiscardAnyUnstagedFileChanges is a function. +func TestGitCommandDiscardAnyUnstagedFileChanges(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(error) + } + + scenarios := []scenario{ + { + "valid case", + test.CreateMockCommand(t, []*test.CommandSwapper{ + { + Expect: `git checkout -- .`, + Replace: "echo", + }, + }), + func(err error) { + assert.NoError(t, err) + }, + }, + } + + gitCmd := NewDummyGitCommand() + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd.OSCommand.Command = s.command + s.test(gitCmd.DiscardAnyUnstagedFileChanges()) + }) + } +} + +// TestGitCommandRemoveUntrackedFiles is a function. +func TestGitCommandRemoveUntrackedFiles(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(error) + } + + scenarios := []scenario{ + { + "valid case", + test.CreateMockCommand(t, []*test.CommandSwapper{ + { + Expect: `git clean -fd`, + Replace: "echo", + }, + }), + func(err error) { + assert.NoError(t, err) + }, + }, + } + + gitCmd := NewDummyGitCommand() + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd.OSCommand.Command = s.command + s.test(gitCmd.RemoveUntrackedFiles()) + }) + } +} + +// TestEditFileCmdStr is a function. +func TestEditFileCmdStr(t *testing.T) { + type scenario struct { + filename string + command func(string, ...string) *exec.Cmd + getenv func(string) string + getGitConfigValue func(string) (string, error) + test func(string, error) + } + + scenarios := []scenario{ + { + "test", + func(name string, arg ...string) *exec.Cmd { + return secureexec.Command("exit", "1") + }, + func(env string) string { + return "" + }, + func(cf string) (string, error) { + return "", nil + }, + func(cmdStr string, err error) { + assert.EqualError(t, err, "No editor defined in $GIT_EDITOR, $VISUAL, $EDITOR, or git config") + }, + }, + { + "test", + func(name string, arg ...string) *exec.Cmd { + assert.Equal(t, "which", name) + return secureexec.Command("exit", "1") + }, + func(env string) string { + return "" + }, + func(cf string) (string, error) { + return "nano", nil + }, + func(cmdStr string, err error) { + assert.NoError(t, err) + assert.Equal(t, "nano \"test\"", cmdStr) + }, + }, + { + "test", + func(name string, arg ...string) *exec.Cmd { + assert.Equal(t, "which", name) + return secureexec.Command("exit", "1") + }, + func(env string) string { + if env == "VISUAL" { + return "nano" + } + + return "" + }, + func(cf string) (string, error) { + return "", nil + }, + func(cmdStr string, err error) { + assert.NoError(t, err) + }, + }, + { + "test", + func(name string, arg ...string) *exec.Cmd { + assert.Equal(t, "which", name) + return secureexec.Command("exit", "1") + }, + func(env string) string { + if env == "EDITOR" { + return "emacs" + } + + return "" + }, + func(cf string) (string, error) { + return "", nil + }, + func(cmdStr string, err error) { + assert.NoError(t, err) + assert.Equal(t, "emacs \"test\"", cmdStr) + }, + }, + { + "test", + func(name string, arg ...string) *exec.Cmd { + assert.Equal(t, "which", name) + return secureexec.Command("echo") + }, + func(env string) string { + return "" + }, + func(cf string) (string, error) { + return "", nil + }, + func(cmdStr string, err error) { + assert.NoError(t, err) + assert.Equal(t, "vi \"test\"", cmdStr) + }, + }, + { + "file/with space", + func(name string, args ...string) *exec.Cmd { + assert.Equal(t, "which", name) + return secureexec.Command("echo") + }, + func(env string) string { + return "" + }, + func(cf string) (string, error) { + return "", nil + }, + func(cmdStr string, err error) { + assert.NoError(t, err) + assert.Equal(t, "vi \"file/with space\"", cmdStr) + }, + }, + } + + for _, s := range scenarios { + gitCmd := NewDummyGitCommand() + gitCmd.OSCommand.Command = s.command + gitCmd.OSCommand.Getenv = s.getenv + gitCmd.getGitConfigValue = s.getGitConfigValue + s.test(gitCmd.EditFileCmdStr(s.filename)) + } +} diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 0c15b2788..2745c1935 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -33,7 +33,6 @@ type GitCommand struct { Tr *i18n.TranslationSet Config config.AppConfigurer getGitConfigValue func(string) (string, error) - removeFile func(string) error DotGitDir string onSuccessfulContinue func() error PatchManager *patch.PatchManager @@ -75,7 +74,6 @@ func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n. Repo: repo, Config: config, getGitConfigValue: getGitConfigValue, - removeFile: os.RemoveAll, DotGitDir: dotGitDir, PushToCurrent: pushToCurrent, } @@ -85,6 +83,14 @@ func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n. return gitCommand, nil } +func (c *GitCommand) WithSpan(span string) *GitCommand { + newGitCommand := &GitCommand{} + *newGitCommand = *c + newGitCommand.OSCommand = c.OSCommand.WithSpan(span) + newGitCommand.PatchManager.ApplyPatch = newGitCommand.ApplyPatch + return newGitCommand +} + func navigateToRepoRootDirectory(stat func(string) (os.FileInfo, error), chdir func(string) error) error { gitDir := env.GetGitDirEnv() if gitDir != "" { diff --git a/pkg/commands/oscommands/exec_live_default.go b/pkg/commands/oscommands/exec_live_default.go index 6f51ecedc..124792840 100644 --- a/pkg/commands/oscommands/exec_live_default.go +++ b/pkg/commands/oscommands/exec_live_default.go @@ -20,6 +20,7 @@ import ( // NOTE: If the return data is empty it won't written anything to stdin func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) error { c.Log.WithField("command", command).Info("RunCommand") + c.LogCommand(command, true) cmd := c.ExecutableFromString(command) cmd.Env = append(cmd.Env, "LANG=en_US.UTF-8", "LC_ALL=en_US.UTF-8") diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 5b9b4dd91..2c85cfc5a 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -40,7 +40,44 @@ type OSCommand struct { Command func(string, ...string) *exec.Cmd BeforeExecuteCmd func(*exec.Cmd) Getenv func(string) string |