Turn runSkipEditorCommand into a function that only sets up the editor

The next commit needs a "git rebase --continue" command with this setup
that the git command runner runs, rather than one that we run directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-08 14:54:41 +01:00
co-authored by Claude Opus 5.5
parent 3a538fc2a8
commit 3dcad25058
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -408,7 +408,7 @@ func (self *RebaseCommands) SquashAllAboveFixupCommits(commit *models.Commit) er
Arg("--interactive", "--rebase-merges", "--autostash", "--autosquash", hashOrRoot).
ToArgv()
return self.runSkipEditorCommand(self.cmd.New(cmdArgs))
return skipEditor(self.cmd.New(cmdArgs)).Run()
}
// BeginInteractiveRebaseForCommit starts an interactive rebase to edit the current
@@ -491,7 +491,7 @@ func (self *RebaseCommands) AbortRebase() error {
// GenericMerge takes a commandType of "merge" or "rebase" and a command of "abort", "skip" or "continue"
// By default we skip the editor in the case where a commit will be made
func (self *RebaseCommands) GenericMergeOrRebaseAction(commandType string, command string) error {
err := self.runSkipEditorCommand(self.GenericMergeOrRebaseActionCmdObj(commandType, command))
err := skipEditor(self.GenericMergeOrRebaseActionCmdObj(commandType, command)).Run()
if err != nil {
if !strings.Contains(err.Error(), "no rebase in progress") {
return err
@@ -513,7 +513,9 @@ func (self *RebaseCommands) GenericMergeOrRebaseAction(commandType string, comma
return nil
}
func (self *RebaseCommands) runSkipEditorCommand(cmdObj *oscommands.CmdObj) error {
// skipEditor makes git use lazygit as the editor for the given command; lazygit
// then exits right away, so git uses the file as it is.
func skipEditor(cmdObj *oscommands.CmdObj) *oscommands.CmdObj {
instruction := daemon.NewExitImmediatelyInstruction()
lazyGitPath := oscommands.GetLazygitPath()
return cmdObj.
@@ -523,8 +525,7 @@ func (self *RebaseCommands) runSkipEditorCommand(cmdObj *oscommands.CmdObj) erro
"EDITOR="+lazyGitPath,
"VISUAL="+lazyGitPath,
).
AddEnvVars(daemon.ToEnvVars(instruction)...).
Run()
AddEnvVars(daemon.ToEnvVars(instruction)...)
}
// DiscardOldFileChanges discards changes to a file from an old commit
+1 -1
View File
@@ -89,7 +89,7 @@ func TestRebaseSkipEditorCommand(t *testing.T) {
return true
}, "", nil)
instance := buildRebaseCommands(commonDeps{runner: runner})
err := instance.runSkipEditorCommand(instance.cmd.New(cmdArgs))
err := skipEditor(instance.cmd.New(cmdArgs)).Run()
assert.NoError(t, err)
runner.CheckForMissingCalls()
}