summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/patch.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-03-20 16:19:27 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-24 20:14:41 +1100
commit43d3f2bcb6094293156841f6670577720bab2314 (patch)
treef5a7bfdb3b9d475044e1d10fa6373b306d1e6fd3 /pkg/commands/git_commands/patch.go
parent99e55725fb0783bc3280498ec6047350368c25d7 (diff)
refactor todo file generation
Diffstat (limited to 'pkg/commands/git_commands/patch.go')
-rw-r--r--pkg/commands/git_commands/patch.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/pkg/commands/git_commands/patch.go b/pkg/commands/git_commands/patch.go
index 8f9ce5784..a805c7f21 100644
--- a/pkg/commands/git_commands/patch.go
+++ b/pkg/commands/git_commands/patch.go
@@ -105,16 +105,16 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s
}
baseIndex := sourceCommitIdx + 1
- todo := ""
- for i, commit := range commits[0:baseIndex] {
- a := "pick"
+
+ todoLines := self.rebase.BuildTodoLines(commits[0:baseIndex], func(commit *models.Commit, i int) string {
if i == sourceCommitIdx || i == destinationCommitIdx {
- a = "edit"
+ return "edit"
+ } else {
+ return "pick"
}
- todo = a + " " + commit.Sha + " " + commit.Name + "\n" + todo
- }
+ })
- err := self.rebase.PrepareInteractiveRebaseCommand(commits[baseIndex].Sha, todo, true).Run()
+ err := self.rebase.PrepareInteractiveRebaseCommand(commits[baseIndex].Sha, todoLines, true).Run()
if err != nil {
return err
}