mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
use platform-specific message quoting
This commit is contained in:
@ -104,7 +104,7 @@ func (c *GitCommand) StashDo(index int, method string) (string, error) {
|
|||||||
|
|
||||||
// StashSave save stash
|
// StashSave save stash
|
||||||
func (c *GitCommand) StashSave(message string) (string, error) {
|
func (c *GitCommand) StashSave(message string) (string, error) {
|
||||||
output, err := c.OSCommand.RunCommand("git stash save \"" + message + "\"")
|
output, err := c.OSCommand.RunCommand("git stash save " + c.OSCommand.Quote(message))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return output, err
|
return output, err
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ func (c *GitCommand) GetCommitsToPush() []string {
|
|||||||
|
|
||||||
// RenameCommit renames the topmost commit with the given name
|
// RenameCommit renames the topmost commit with the given name
|
||||||
func (c *GitCommand) RenameCommit(name string) (string, error) {
|
func (c *GitCommand) RenameCommit(name string) (string, error) {
|
||||||
return c.OSCommand.RunDirectCommand("git commit --allow-empty --amend -m \"" + name + "\"")
|
return c.OSCommand.RunDirectCommand("git commit --allow-empty --amend -m " + c.OSCommand.Quote(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch fetch git repo
|
// Fetch fetch git repo
|
||||||
@ -265,7 +265,7 @@ func (c *GitCommand) UsingGpg() bool {
|
|||||||
|
|
||||||
// Commit commit to git
|
// Commit commit to git
|
||||||
func (c *GitCommand) Commit(g *gocui.Gui, message string) (*exec.Cmd, error) {
|
func (c *GitCommand) Commit(g *gocui.Gui, message string) (*exec.Cmd, error) {
|
||||||
command := "git commit -m \"" + message + "\""
|
command := "git commit -m " + c.OSCommand.Quote(message)
|
||||||
if c.UsingGpg() {
|
if c.UsingGpg() {
|
||||||
return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command)
|
return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command)
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ func (c *GitCommand) Push(branchName string) (string, error) {
|
|||||||
// SquashPreviousTwoCommits squashes a commit down to the one below it
|
// SquashPreviousTwoCommits squashes a commit down to the one below it
|
||||||
// retaining the message of the higher commit
|
// retaining the message of the higher commit
|
||||||
func (c *GitCommand) SquashPreviousTwoCommits(message string) (string, error) {
|
func (c *GitCommand) SquashPreviousTwoCommits(message string) (string, error) {
|
||||||
return c.OSCommand.RunDirectCommand("git reset --soft HEAD^ && git commit --amend -m \"" + message + "\"")
|
return c.OSCommand.RunDirectCommand("git reset --soft HEAD^ && git commit --amend -m " + c.OSCommand.Quote(message))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SquashFixupCommit squashes a 'FIXUP' commit into the commit beneath it,
|
// SquashFixupCommit squashes a 'FIXUP' commit into the commit beneath it,
|
||||||
|
@ -155,3 +155,8 @@ func (c *OSCommand) PrepareSubProcess(cmdName string, commandArgs ...string) (*e
|
|||||||
subprocess := exec.Command(cmdName, commandArgs...)
|
subprocess := exec.Command(cmdName, commandArgs...)
|
||||||
return subprocess, nil
|
return subprocess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quote wraps a message in platform-specific quotation marks
|
||||||
|
func (c *OSCommand) Quote(message string) string {
|
||||||
|
return c.Platform.escapedQuote + message + c.Platform.escapedQuote
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user