1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03:00

fix merge conflict cat issue on windows

This commit is contained in:
Jesse Duffield
2021-04-02 12:55:50 +11:00
parent 8b7f7cbc30
commit 8901d11674
4 changed files with 16 additions and 4 deletions

View File

@ -16,7 +16,7 @@ import (
// CatFile obtains the content of a file
func (c *GitCommand) CatFile(fileName string) (string, error) {
return c.OSCommand.RunCommandWithOutput("%s %s", c.OSCommand.Platform.CatCmd, c.OSCommand.Quote(fileName))
return c.OSCommand.CatFile(fileName)
}
// StageFile stages a file

View File

@ -24,7 +24,7 @@ import (
// Platform stores the os state
type Platform struct {
OS string
CatCmd string
CatCmd []string
Shell string
ShellArg string
EscapedQuote string
@ -100,6 +100,18 @@ func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...inte
return output, err
}
func (c *OSCommand) CatFile(filename string) (string, error) {
arr := append(c.Platform.CatCmd, filename)
cmdStr := strings.Join(arr, " ")
c.Log.WithField("command", cmdStr).Info("Cat")
cmd := c.Command(arr[0], arr[1:]...)
output, err := sanitisedCommandOutput(cmd.CombinedOutput())
if err != nil {
c.Log.WithField("command", cmdStr).Error(err)
}
return output, err
}
// RunExecutableWithOutput runs an executable file and returns its output
func (c *OSCommand) RunExecutableWithOutput(cmd *exec.Cmd) (string, error) {
c.BeforeExecuteCmd(cmd)

View File

@ -9,7 +9,7 @@ import (
func getPlatform() *Platform {
return &Platform{
OS: runtime.GOOS,
CatCmd: "cat",
CatCmd: []string{"cat"},
Shell: "bash",
ShellArg: "-c",
EscapedQuote: `"`,

View File

@ -3,7 +3,7 @@ package oscommands
func getPlatform() *Platform {
return &Platform{
OS: "windows",
CatCmd: "cmd /c type",
CatCmd: []string{"cmd", "/c", "type"},
Shell: "cmd",
ShellArg: "/c",
EscapedQuote: `\"`,