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:
@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
// CatFile obtains the content of a file
|
// CatFile obtains the content of a file
|
||||||
func (c *GitCommand) CatFile(fileName string) (string, error) {
|
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
|
// StageFile stages a file
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
// Platform stores the os state
|
// Platform stores the os state
|
||||||
type Platform struct {
|
type Platform struct {
|
||||||
OS string
|
OS string
|
||||||
CatCmd string
|
CatCmd []string
|
||||||
Shell string
|
Shell string
|
||||||
ShellArg string
|
ShellArg string
|
||||||
EscapedQuote string
|
EscapedQuote string
|
||||||
@ -100,6 +100,18 @@ func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...inte
|
|||||||
return output, err
|
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
|
// RunExecutableWithOutput runs an executable file and returns its output
|
||||||
func (c *OSCommand) RunExecutableWithOutput(cmd *exec.Cmd) (string, error) {
|
func (c *OSCommand) RunExecutableWithOutput(cmd *exec.Cmd) (string, error) {
|
||||||
c.BeforeExecuteCmd(cmd)
|
c.BeforeExecuteCmd(cmd)
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
func getPlatform() *Platform {
|
func getPlatform() *Platform {
|
||||||
return &Platform{
|
return &Platform{
|
||||||
OS: runtime.GOOS,
|
OS: runtime.GOOS,
|
||||||
CatCmd: "cat",
|
CatCmd: []string{"cat"},
|
||||||
Shell: "bash",
|
Shell: "bash",
|
||||||
ShellArg: "-c",
|
ShellArg: "-c",
|
||||||
EscapedQuote: `"`,
|
EscapedQuote: `"`,
|
||||||
|
@ -3,7 +3,7 @@ package oscommands
|
|||||||
func getPlatform() *Platform {
|
func getPlatform() *Platform {
|
||||||
return &Platform{
|
return &Platform{
|
||||||
OS: "windows",
|
OS: "windows",
|
||||||
CatCmd: "cmd /c type",
|
CatCmd: []string{"cmd", "/c", "type"},
|
||||||
Shell: "cmd",
|
Shell: "cmd",
|
||||||
ShellArg: "/c",
|
ShellArg: "/c",
|
||||||
EscapedQuote: `\"`,
|
EscapedQuote: `\"`,
|
||||||
|
Reference in New Issue
Block a user