diff --git a/pkg/app/app.go b/pkg/app/app.go index 4fcbdc5b8..c1a28ff1c 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -122,7 +122,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) { return app, nil } - app.OSCommand = oscommands.NewOSCommand(app.Common) + app.OSCommand = oscommands.NewOSCommand(app.Common, oscommands.GetPlatform()) app.Updater, err = updates.NewUpdater(app.Common, config, app.OSCommand) if err != nil { diff --git a/pkg/commands/branches_test.go b/pkg/commands/branches_test.go index 58a3e1cc4..633d4784e 100644 --- a/pkg/commands/branches_test.go +++ b/pkg/commands/branches_test.go @@ -142,8 +142,8 @@ func TestGitCommandCheckout(t *testing.T) { } func TestGitCommandGetBranchGraph(t *testing.T) { - runner := oscommands.NewFakeRunner(t).ExpectArgs([]string{ - "git", "log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--", + runner := oscommands.NewFakeRunner(t).ExpectGitArgs([]string{ + "log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--", }, "", nil) gitCmd := NewDummyGitCommandWithRunner(runner) _, err := gitCmd.GetBranchGraph("test") @@ -151,8 +151,8 @@ func TestGitCommandGetBranchGraph(t *testing.T) { } func TestGitCommandGetAllBranchGraph(t *testing.T) { - runner := oscommands.NewFakeRunner(t).ExpectArgs([]string{ - "git", "log", "--graph", "--all", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", + runner := oscommands.NewFakeRunner(t).ExpectGitArgs([]string{ + "log", "--graph", "--all", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", }, "", nil) gitCmd := NewDummyGitCommandWithRunner(runner) cmdStr := gitCmd.UserConfig.Git.AllBranchesLogCmd diff --git a/pkg/commands/commits_test.go b/pkg/commands/commits_test.go index 4ca36969a..bdefc4c0e 100644 --- a/pkg/commands/commits_test.go +++ b/pkg/commands/commits_test.go @@ -9,7 +9,7 @@ import ( func TestGitCommandRenameCommit(t *testing.T) { runner := oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "commit", "--allow-empty", "--amend", "--only", "-m", "test"}, "", nil) + ExpectGitArgs([]string{"commit", "--allow-empty", "--amend", "--only", "-m", "test"}, "", nil) gitCmd := NewDummyGitCommandWithRunner(runner) assert.NoError(t, gitCmd.RenameCommit("test")) @@ -18,7 +18,7 @@ func TestGitCommandRenameCommit(t *testing.T) { func TestGitCommandResetToCommit(t *testing.T) { runner := oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "reset", "--hard", "78976bc"}, "", nil) + ExpectGitArgs([]string{"reset", "--hard", "78976bc"}, "", nil) gitCmd := NewDummyGitCommandWithRunner(runner) assert.NoError(t, gitCmd.ResetToCommit("78976bc", "hard", []string{})) @@ -26,8 +26,6 @@ func TestGitCommandResetToCommit(t *testing.T) { } func TestGitCommandCommitObj(t *testing.T) { - gitCmd := NewDummyGitCommand() - type scenario struct { testName string message string @@ -40,24 +38,25 @@ func TestGitCommandCommitObj(t *testing.T) { testName: "Commit", message: "test", flags: "", - expected: "git commit -m " + gitCmd.OSCommand.Quote("test"), + expected: `git commit -m "test"`, }, { testName: "Commit with --no-verify flag", message: "test", flags: "--no-verify", - expected: "git commit --no-verify -m " + gitCmd.OSCommand.Quote("test"), + expected: `git commit --no-verify -m "test"`, }, { testName: "Commit with multiline message", message: "line1\nline2", flags: "", - expected: "git commit -m " + gitCmd.OSCommand.Quote("line1") + " -m " + gitCmd.OSCommand.Quote("line2"), + expected: `git commit -m "line1" -m "line2"`, }, } for _, s := range scenarios { t.Run(s.testName, func(t *testing.T) { + gitCmd := NewDummyGitCommand() cmdStr := gitCmd.CommitCmdObj(s.message, s.flags).ToString() assert.Equal(t, s.expected, cmdStr) }) @@ -101,8 +100,6 @@ func TestGitCommandShowCmdObj(t *testing.T) { expected string } - gitCmd := NewDummyGitCommand() - scenarios := []scenario{ { testName: "Default case without filter path", @@ -114,7 +111,7 @@ func TestGitCommandShowCmdObj(t *testing.T) { testName: "Default case with filter path", filterPath: "file.txt", contextSize: 3, - expected: "git show --submodule --color=always --unified=3 --no-renames --stat -p 1234567890 -- " + gitCmd.OSCommand.Quote("file.txt"), + expected: `git show --submodule --color=always --unified=3 --no-renames --stat -p 1234567890 -- "file.txt"`, }, { testName: "Show diff with custom context size", @@ -126,6 +123,7 @@ func TestGitCommandShowCmdObj(t *testing.T) { for _, s := range scenarios { t.Run(s.testName, func(t *testing.T) { + gitCmd := NewDummyGitCommand() gitCmd.UserConfig.Git.DiffContextSize = s.contextSize cmdStr := gitCmd.ShowCmdObj("1234567890", s.filterPath).ToString() assert.Equal(t, s.expected, cmdStr) diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go index 126007baa..ae6ba81e9 100644 --- a/pkg/commands/dummies.go +++ b/pkg/commands/dummies.go @@ -16,8 +16,12 @@ func NewDummyGitCommand() *GitCommand { // NewDummyGitCommandWithOSCommand creates a new dummy GitCommand for testing func NewDummyGitCommandWithOSCommand(osCommand *oscommands.OSCommand) *GitCommand { + runner := &oscommands.FakeCmdObjRunner{} + builder := oscommands.NewDummyCmdObjBuilder(runner) + return &GitCommand{ Common: utils.NewDummyCommon(), + Cmd: builder, OSCommand: osCommand, GitConfig: git_config.NewFakeGitConfig(map[string]string{}), GetCmdWriter: func() io.Writer { return ioutil.Discard }, diff --git a/pkg/commands/files_test.go b/pkg/commands/files_test.go index f5e9d155c..9c42e7b45 100644 --- a/pkg/commands/files_test.go +++ b/pkg/commands/files_test.go @@ -15,7 +15,7 @@ import ( func TestGitCommandStageFile(t *testing.T) { runner := oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "add", "--", "test.txt"}, "", nil) + ExpectGitArgs([]string{"add", "--", "test.txt"}, "", nil) gitCmd := NewDummyGitCommandWithRunner(runner) assert.NoError(t, gitCmd.StageFile("test.txt")) @@ -35,7 +35,7 @@ func TestGitCommandUnstageFile(t *testing.T) { testName: "Remove an untracked file from staging", reset: false, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "rm", "--cached", "--force", "--", "test.txt"}, "", nil), + ExpectGitArgs([]string{"rm", "--cached", "--force", "--", "test.txt"}, "", nil), test: func(err error) { assert.NoError(t, err) }, @@ -44,7 +44,7 @@ func TestGitCommandUnstageFile(t *testing.T) { testName: "Remove a tracked file from staging", reset: true, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "reset", "HEAD", "--", "test.txt"}, "", nil), + ExpectGitArgs([]string{"reset", "HEAD", "--", "test.txt"}, "", nil), test: func(err error) { assert.NoError(t, err) }, @@ -80,7 +80,7 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { }, removeFile: func(string) error { return nil }, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "reset", "--", "test"}, "", errors.New("error")), + ExpectGitArgs([]string{"reset", "--", "test"}, "", errors.New("error")), expectedError: "error", }, { @@ -105,7 +105,7 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { }, removeFile: func(string) error { return nil }, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "checkout", "--", "test"}, "", errors.New("error")), + ExpectGitArgs([]string{"checkout", "--", "test"}, "", errors.New("error")), expectedError: "error", }, { @@ -117,7 +117,7 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { }, removeFile: func(string) error { return nil }, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "checkout", "--", "test"}, "", nil), + ExpectGitArgs([]string{"checkout", "--", "test"}, "", nil), expectedError: "", }, { @@ -129,8 +129,8 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { }, removeFile: func(string) error { return nil }, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "reset", "--", "test"}, "", nil). - ExpectArgs([]string{"git", "checkout", "--", "test"}, "", nil), + ExpectGitArgs([]string{"reset", "--", "test"}, "", nil). + ExpectGitArgs([]string{"checkout", "--", "test"}, "", nil), expectedError: "", }, { @@ -142,8 +142,8 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { }, removeFile: func(string) error { return nil }, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "reset", "--", "test"}, "", nil). - ExpectArgs([]string{"git", "checkout", "--", "test"}, "", nil), + ExpectGitArgs([]string{"reset", "--", "test"}, "", nil). + ExpectGitArgs([]string{"checkout", "--", "test"}, "", nil), expectedError: "", }, { @@ -159,7 +159,7 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { return nil }, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "reset", "--", "test"}, "", nil), + ExpectGitArgs([]string{"reset", "--", "test"}, "", nil), expectedError: "", }, { @@ -221,7 +221,7 @@ func TestGitCommandDiff(t *testing.T) { ignoreWhitespace: false, contextSize: 3, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--", "test.txt"}, expectedResult, nil), }, { testName: "cached", @@ -235,7 +235,7 @@ func TestGitCommandDiff(t *testing.T) { ignoreWhitespace: false, contextSize: 3, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--cached", "--", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--cached", "--", "test.txt"}, expectedResult, nil), }, { testName: "plain", @@ -249,7 +249,7 @@ func TestGitCommandDiff(t *testing.T) { ignoreWhitespace: false, contextSize: 3, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=never", "--", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=never", "--", "test.txt"}, expectedResult, nil), }, { testName: "File not tracked and file has no staged changes", @@ -263,7 +263,7 @@ func TestGitCommandDiff(t *testing.T) { ignoreWhitespace: false, contextSize: 3, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--no-index", "--", "/dev/null", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--no-index", "--", "/dev/null", "test.txt"}, expectedResult, nil), }, { testName: "Default case (ignore whitespace)", @@ -277,7 +277,7 @@ func TestGitCommandDiff(t *testing.T) { ignoreWhitespace: true, contextSize: 3, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--ignore-all-space", "--", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=3", "--color=always", "--ignore-all-space", "--", "test.txt"}, expectedResult, nil), }, { testName: "Show diff with custom context size", @@ -291,7 +291,7 @@ func TestGitCommandDiff(t *testing.T) { ignoreWhitespace: false, contextSize: 17, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=17", "--color=always", "--", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=17", "--color=always", "--", "test.txt"}, expectedResult, nil), }, } @@ -328,7 +328,7 @@ func TestGitCommandShowFileDiff(t *testing.T) { plain: false, contextSize: 3, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=3", "--no-renames", "--color=always", "1234567890", "0987654321", "--", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=3", "--no-renames", "--color=always", "1234567890", "0987654321", "--", "test.txt"}, expectedResult, nil), }, { testName: "Show diff with custom context size", @@ -338,7 +338,7 @@ func TestGitCommandShowFileDiff(t *testing.T) { plain: false, contextSize: 123, runner: oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "diff", "--submodule", "--no-ext-diff", "--unified=123", "--no-renames", "--color=always", "1234567890", "0987654321", "--", "test.txt"}, expectedResult, nil), + ExpectGitArgs([]string{"diff", "--submodule", "--no-ext-diff", "--unified=123", "--no-renames", "--color=always", "1234567890", "0987654321", "--", "test.txt"}, expectedResult, nil), }, } diff --git a/pkg/commands/oscommands/cmd_obj_builder.go b/pkg/commands/oscommands/cmd_obj_builder.go index 85e28f566..633cee322 100644 --- a/pkg/commands/oscommands/cmd_obj_builder.go +++ b/pkg/commands/oscommands/cmd_obj_builder.go @@ -1,6 +1,7 @@ package oscommands import ( + "fmt" "os" "strings" @@ -54,7 +55,23 @@ func (self *CmdObjBuilder) NewFromArgs(args []string) ICmdObj { } func (self *CmdObjBuilder) NewShell(commandStr string) ICmdObj { - return self.NewFromArgs([]string{self.platform.Shell, self.platform.ShellArg, commandStr}) + quotedCommand := "" + // Windows does not seem to like quotes around the command + if self.platform.OS == "windows" { + quotedCommand = strings.NewReplacer( + "^", "^^", + "&", "^&", + "|", "^|", + "<", "^<", + ">", "^>", + "%", "^%", + ).Replace(commandStr) + } else { + quotedCommand = self.Quote(commandStr) + } + + shellCommand := fmt.Sprintf("%s %s %s", self.platform.Shell, self.platform.ShellArg, quotedCommand) + return self.New(shellCommand) } func (self *CmdObjBuilder) CloneWithNewRunner(decorate func(ICmdObjRunner) ICmdObjRunner) *CmdObjBuilder { diff --git a/pkg/commands/oscommands/dummies.go b/pkg/commands/oscommands/dummies.go index d77993e62..f44cc9b72 100644 --- a/pkg/commands/oscommands/dummies.go +++ b/pkg/commands/oscommands/dummies.go @@ -6,25 +6,29 @@ import ( // NewDummyOSCommand creates a new dummy OSCommand for testing func NewDummyOSCommand() *OSCommand { - return NewOSCommand(utils.NewDummyCommon()) + osCmd := NewOSCommand(utils.NewDummyCommon(), dummyPlatform) + + return osCmd } func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder { return &CmdObjBuilder{ runner: runner, logCmdObj: func(ICmdObj) {}, - platform: &Platform{ - OS: "darwin", - Shell: "bash", - ShellArg: "-c", - OpenCommand: "open {{filename}}", - OpenLinkCommand: "open {{link}}", - }, + 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()) + osCommand := NewOSCommand(utils.NewDummyCommon(), dummyPlatform) osCommand.Cmd = NewDummyCmdObjBuilder(runner) return osCommand diff --git a/pkg/commands/oscommands/fake_cmd_obj_runner.go b/pkg/commands/oscommands/fake_cmd_obj_runner.go index 9a8a1e798..b542bfee3 100644 --- a/pkg/commands/oscommands/fake_cmd_obj_runner.go +++ b/pkg/commands/oscommands/fake_cmd_obj_runner.go @@ -3,6 +3,7 @@ package oscommands import ( "bufio" "fmt" + "regexp" "strings" "testing" @@ -93,10 +94,24 @@ func (self *FakeCmdObjRunner) ExpectArgs(expectedArgs []string, output string, e return self } +func (self *FakeCmdObjRunner) ExpectGitArgs(expectedArgs []string, output string, err error) *FakeCmdObjRunner { + self.ExpectFunc(func(cmdObj ICmdObj) (string, error) { + // first arg is 'git' on unix and something like '"C:\\Program Files\\Git\\mingw64\\bin\\git.exe" on windows so we'll just ensure it ends in either 'git' or 'git.exe' + re := regexp.MustCompile(`git(\.exe)?$`) + args := cmdObj.GetCmd().Args + if !re.MatchString(args[0]) { + self.t.Errorf("expected first arg to end in .git or .git.exe but was %s", args[0]) + } + assert.EqualValues(self.t, expectedArgs, args[1:], fmt.Sprintf("command %d did not match expectation", self.expectedCmdIndex+1)) + + return output, err + }) + + return self +} + func (self *FakeCmdObjRunner) CheckForMissingCalls() { if self.expectedCmdIndex < len(self.expectedCmds) { self.t.Errorf("expected command %d to be called, but was not", self.expectedCmdIndex+1) } - - return } diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 5a7c5e0bb..c5c6e3649 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -73,9 +73,7 @@ func NewCmdLogEntry(cmdStr string, span string, commandLine bool) CmdLogEntry { } // NewOSCommand os command runner -func NewOSCommand(common *common.Common) *OSCommand { - platform := getPlatform() - +func NewOSCommand(common *common.Common, platform *Platform) *OSCommand { c := &OSCommand{ Common: common, Platform: platform, @@ -138,7 +136,6 @@ func FileType(path string) string { return "file" } -// OpenFile opens a file with the given func (c *OSCommand) OpenFile(filename string) error { commandTemplate := c.UserConfig.OS.OpenCommand templateValues := map[string]string{ @@ -148,7 +145,6 @@ func (c *OSCommand) OpenFile(filename string) error { return c.Cmd.NewShell(command).Run() } -// OpenLink opens a file with the given func (c *OSCommand) OpenLink(link string) error { c.LogCommand(fmt.Sprintf("Opening link '%s'", link), false) commandTemplate := c.UserConfig.OS.OpenLinkCommand diff --git a/pkg/commands/oscommands/os_default_platform.go b/pkg/commands/oscommands/os_default_platform.go index f5b1f4dbc..fd4967d95 100644 --- a/pkg/commands/oscommands/os_default_platform.go +++ b/pkg/commands/oscommands/os_default_platform.go @@ -7,7 +7,7 @@ import ( "runtime" ) -func getPlatform() *Platform { +func GetPlatform() *Platform { return &Platform{ OS: runtime.GOOS, Shell: "bash", diff --git a/pkg/commands/oscommands/os_default_test.go b/pkg/commands/oscommands/os_test_default.go similarity index 63% rename from pkg/commands/oscommands/os_default_test.go rename to pkg/commands/oscommands/os_test_default.go index e53514ddd..f4c1221ed 100644 --- a/pkg/commands/oscommands/os_default_test.go +++ b/pkg/commands/oscommands/os_test_default.go @@ -112,68 +112,3 @@ func TestOSCommandOpenFileLinux(t *testing.T) { s.test(oSCmd.OpenFile(s.filename)) } } - -func TestOSCommandOpenFileWindows(t *testing.T) { - type scenario struct { - filename string - runner *FakeCmdObjRunner - test func(error) - } - - scenarios := []scenario{ - { - filename: "test", - runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "test"}, "", errors.New("error")), - test: func(err error) { - assert.Error(t, err) - }, - }, - { - filename: "test", - runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "test"}, "", nil), - test: func(err error) { - assert.NoError(t, err) - }, - }, - { - filename: "filename with spaces", - runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "filename with spaces"}, "", nil), - test: func(err error) { - assert.NoError(t, err) - }, - }, - { - filename: "let's_test_with_single_quote", - runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "let's_test_with_single_quote"}, "", nil), - test: func(err error) { - assert.NoError(t, err) - }, - }, - { - filename: "$USER.txt", - runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "$USER.txt"}, "", nil), - test: func(err error) { - assert.NoError(t, err) - }, - }, - } - - for _, s := range scenarios { - oSCmd := NewDummyOSCommandWithRunner(s.runner) - platform := &Platform{ - OS: "windows", - Shell: "cmd", - ShellArg: "/c", - } - oSCmd.Platform = platform - oSCmd.Cmd.platform = platform - oSCmd.UserConfig.OS.OpenCommand = `start "" {{filename}}` - - s.test(oSCmd.OpenFile(s.filename)) - } -} diff --git a/pkg/commands/oscommands/os_windows_test.go b/pkg/commands/oscommands/os_test_windows.go similarity index 92% rename from pkg/commands/oscommands/os_windows_test.go rename to pkg/commands/oscommands/os_test_windows.go index 5f2eefa9f..cf9c1e68a 100644 --- a/pkg/commands/oscommands/os_windows_test.go +++ b/pkg/commands/oscommands/os_test_windows.go @@ -4,18 +4,18 @@ package oscommands import ( - "os/exec" "testing" - "github.com/jesseduffield/lazygit/pkg/secureexec" + "github.com/go-errors/errors" "github.com/stretchr/testify/assert" ) +// handling this in a separate file because str.ToArgv has different behaviour if we're on windows + func TestOSCommandOpenFileWindows(t *testing.T) { type scenario struct { filename string runner *FakeCmdObjRunner - command func(string, ...string) *exec.Cmd test func(error) } diff --git a/pkg/commands/oscommands/os_windows.go b/pkg/commands/oscommands/os_windows.go index f3b3b4056..783f50518 100644 --- a/pkg/commands/oscommands/os_windows.go +++ b/pkg/commands/oscommands/os_windows.go @@ -1,6 +1,6 @@ package oscommands -func getPlatform() *Platform { +func GetPlatform() *Platform { return &Platform{ OS: "windows", Shell: "cmd", diff --git a/pkg/commands/stash_entries_test.go b/pkg/commands/stash_entries_test.go index f775b98a6..278ec84fb 100644 --- a/pkg/commands/stash_entries_test.go +++ b/pkg/commands/stash_entries_test.go @@ -9,7 +9,7 @@ import ( func TestGitCommandStashDo(t *testing.T) { runner := oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "stash", "drop", "stash@{1}"}, "", nil) + ExpectGitArgs([]string{"stash", "drop", "stash@{1}"}, "", nil) gitCmd := NewDummyGitCommandWithRunner(runner) assert.NoError(t, gitCmd.StashDo(1, "drop")) @@ -18,7 +18,7 @@ func TestGitCommandStashDo(t *testing.T) { func TestGitCommandStashSave(t *testing.T) { runner := oscommands.NewFakeRunner(t). - ExpectArgs([]string{"git", "stash", "save", "A stash message"}, "", nil) + ExpectGitArgs([]string{"stash", "save", "A stash message"}, "", nil) gitCmd := NewDummyGitCommandWithRunner(runner) assert.NoError(t, gitCmd.StashSave("A stash message")) diff --git a/scripts/push_new_patch/main.go b/scripts/push_new_patch/main.go index 40d95d9a0..a26f2b676 100755 --- a/scripts/push_new_patch/main.go +++ b/scripts/push_new_patch/main.go @@ -18,7 +18,6 @@ import ( ) func main() { - version, err := ioutil.ReadFile("VERSION") if err != nil { log.Panicln(err.Error())