From 99c502725d779037cb7ec86c204110febcec42ee Mon Sep 17 00:00:00 2001 From: Chris McDonnell Date: Sat, 6 Dec 2025 20:59:20 -0500 Subject: [PATCH 1/2] Add signoff flag to revert, merge, and cherrypick --- pkg/commands/git_commands/branch.go | 1 + pkg/commands/git_commands/commit.go | 1 + pkg/commands/git_commands/rebase.go | 1 + 3 files changed, 3 insertions(+) diff --git a/pkg/commands/git_commands/branch.go b/pkg/commands/git_commands/branch.go index cd78a755b..98fc388d1 100644 --- a/pkg/commands/git_commands/branch.go +++ b/pkg/commands/git_commands/branch.go @@ -277,6 +277,7 @@ func (self *BranchCommands) Merge(branchName string, variant MergeVariant) error cmdArgs := NewGitCmd("merge"). Arg("--no-edit"). + ArgIf(self.UserConfig().Git.Commit.SignOff, "--signoff"). Arg(strings.Fields(self.UserConfig().Git.Merging.Args)...). Arg(extraArgs...). Arg(branchName). diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go index 40d2b7319..85067b622 100644 --- a/pkg/commands/git_commands/commit.go +++ b/pkg/commands/git_commands/commit.go @@ -279,6 +279,7 @@ func (self *CommitCommands) ShowFileContentCmdObj(hash string, filePath string) func (self *CommitCommands) Revert(hashes []string, isMerge bool) error { cmdArgs := NewGitCmd("revert"). ArgIf(isMerge, "-m", "1"). + ArgIf(self.UserConfig().Git.Commit.SignOff, "--signoff"). Arg(hashes...). ToArgv() diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go index 152c88bbc..f279767f0 100644 --- a/pkg/commands/git_commands/rebase.go +++ b/pkg/commands/git_commands/rebase.go @@ -558,6 +558,7 @@ func (self *RebaseCommands) CherryPickCommits(commits []*models.Commit) error { hasMergeCommit := lo.SomeBy(commits, func(c *models.Commit) bool { return c.IsMerge() }) cmdArgs := NewGitCmd("cherry-pick"). Arg("--allow-empty"). + ArgIf(self.UserConfig().Git.Commit.SignOff, "--signoff"). ArgIf(self.version.IsAtLeast(2, 45, 0), "--empty=keep", "--keep-redundant-commits"). ArgIf(hasMergeCommit, "-m1"). Arg(lo.Reverse(lo.Map(commits, func(c *models.Commit, _ int) string { return c.Hash() }))...). From acf07e2bbc1790fd7374442f4f86e3b073025035 Mon Sep 17 00:00:00 2001 From: Chris McDonnell Date: Tue, 9 Dec 2025 00:11:35 -0500 Subject: [PATCH 2/2] Inline self.signoffFlag helper --- pkg/commands/git_commands/commit.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go index 85067b622..57251b9c8 100644 --- a/pkg/commands/git_commands/commit.go +++ b/pkg/commands/git_commands/commit.go @@ -90,7 +90,7 @@ func (self *CommitCommands) CommitCmdObj(summary string, description string, for skipHookPrefix := self.UserConfig().Git.SkipHookPrefix cmdArgs := NewGitCmd("commit"). ArgIf(forceSkipHooks || (skipHookPrefix != "" && strings.HasPrefix(summary, skipHookPrefix)), "--no-verify"). - ArgIf(self.signoffFlag() != "", self.signoffFlag()). + ArgIf(self.UserConfig().Git.Commit.SignOff, "--signoff"). Arg(messageArgs...). ToArgv() @@ -111,7 +111,7 @@ func (self *CommitCommands) CommitInEditorWithMessageFileCmdObj(tmpMessageFile s ArgIf(forceSkipHooks, "--no-verify"). Arg("--edit"). Arg("--file="+tmpMessageFile). - ArgIf(self.signoffFlag() != "", self.signoffFlag()). + ArgIf(self.UserConfig().Git.Commit.SignOff, "--signoff"). ToArgv()) } @@ -140,19 +140,12 @@ func (self *CommitCommands) commitMessageArgs(summary string, description string // runs git commit without the -m argument meaning it will invoke the user's editor func (self *CommitCommands) CommitEditorCmdObj() *oscommands.CmdObj { cmdArgs := NewGitCmd("commit"). - ArgIf(self.signoffFlag() != "", self.signoffFlag()). + ArgIf(self.UserConfig().Git.Commit.SignOff, "--signoff"). ToArgv() return self.cmd.New(cmdArgs) } -func (self *CommitCommands) signoffFlag() string { - if self.UserConfig().Git.Commit.SignOff { - return "--signoff" - } - return "" -} - func (self *CommitCommands) GetCommitMessage(commitHash string) (string, error) { cmdArgs := NewGitCmd("log"). Arg("--format=%B", "--max-count=1", commitHash).