diff options
author | Gustavo Krieger <gustavopcassol@gmail.com> | 2023-07-02 01:03:16 -0300 |
---|---|---|
committer | Gustavo Krieger <gustavopcassol@gmail.com> | 2023-07-02 02:07:32 -0300 |
commit | 9ae771085034442e6f73ad538272e9148b5bfe7f (patch) | |
tree | 24c8fec5a8b0d37a1c5c16fd5bd4a31d9024b46f /pkg/app | |
parent | 87fe30d50daf522f656891851d50eb790bbff2fc (diff) |
Use comment char config on interactive rebase
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
Diffstat (limited to 'pkg/app')
-rw-r--r-- | pkg/app/daemon/daemon.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/pkg/app/daemon/daemon.go b/pkg/app/daemon/daemon.go index adc287309..cf10e9a18 100644 --- a/pkg/app/daemon/daemon.go +++ b/pkg/app/daemon/daemon.go @@ -10,6 +10,7 @@ import ( "github.com/fsmiamoto/git-todo-parser/todo" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/common" + "github.com/jesseduffield/lazygit/pkg/secureexec" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) @@ -90,6 +91,15 @@ func getDaemonKind() DaemonKind { return DaemonKind(intValue) } +func getCommentChar() byte { + cmd := secureexec.Command("git", "config", "--get", "--null", "core.commentChar") + if output, err := cmd.Output(); err == nil && len(output) == 2 { + return output[0] + } + + return '#' +} + // An Instruction is a command to be run by lazygit in daemon mode. // It is serialized to json and passed to lazygit via environment variables type Instruction interface { @@ -199,7 +209,7 @@ func (self *ChangeTodoActionsInstruction) SerializedInstructions() string { func (self *ChangeTodoActionsInstruction) run(common *common.Common) error { return handleInteractiveRebase(common, func(path string) error { for _, c := range self.Changes { - if err := utils.EditRebaseTodo(path, c.Sha, todo.Pick, c.NewAction); err != nil { + if err := utils.EditRebaseTodo(path, c.Sha, todo.Pick, c.NewAction, getCommentChar()); err != nil { return err } } @@ -233,7 +243,7 @@ func (self *MoveFixupCommitDownInstruction) SerializedInstructions() string { func (self *MoveFixupCommitDownInstruction) run(common *common.Common) error { return handleInteractiveRebase(common, func(path string) error { - return utils.MoveFixupCommitDown(path, self.OriginalSha, self.FixupSha) + return utils.MoveFixupCommitDown(path, self.OriginalSha, self.FixupSha, getCommentChar()) }) } @@ -257,7 +267,7 @@ func (self *MoveTodoUpInstruction) SerializedInstructions() string { func (self *MoveTodoUpInstruction) run(common *common.Common) error { return handleInteractiveRebase(common, func(path string) error { - return utils.MoveTodoUp(path, self.Sha, todo.Pick) + return utils.MoveTodoUp(path, self.Sha, todo.Pick, getCommentChar()) }) } @@ -281,7 +291,7 @@ func (self *MoveTodoDownInstruction) SerializedInstructions() string { func (self *MoveTodoDownInstruction) run(common *common.Common) error { return handleInteractiveRebase(common, func(path string) error { - return utils.MoveTodoDown(path, self.Sha, todo.Pick) + return utils.MoveTodoDown(path, self.Sha, todo.Pick, getCommentChar()) }) } |