summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-04-06 07:04:25 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-04-29 07:28:33 +0200
commitab25600ccbbc9b8880289c496f521710894e26cc (patch)
tree143fbad1da1f2f38aec9db8718fa4318145afb79 /pkg/commands
parentd50c58b4c669b1de94bf4d04f508b3eb5b84647c (diff)
Extract EditRebaseTodo into a function in utils.rebaseTodo
We want to reuse it from the daemon code in the next commit.
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/rebase.go21
1 files changed, 2 insertions, 19 deletions
diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go
index 26c0536e9..31eaf1366 100644
--- a/pkg/commands/git_commands/rebase.go
+++ b/pkg/commands/git_commands/rebase.go
@@ -231,25 +231,8 @@ func (self *RebaseCommands) AmendTo(commit *models.Commit) error {
// EditRebaseTodo sets the action for a given rebase commit in the git-rebase-todo file
func (self *RebaseCommands) EditRebaseTodo(commit *models.Commit, action todo.TodoCommand) error {
- fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
- todos, err := utils.ReadRebaseTodoFile(fileName)
- if err != nil {
- return err
- }
-
- for i := range todos {
- t := &todos[i]
- // Comparing just the sha is not enough; we need to compare both the
- // action and the sha, as the sha could appear multiple times (e.g. in a
- // pick and later in a merge)
- if t.Command == commit.Action && t.Commit == commit.Sha {
- t.Command = action
- return utils.WriteRebaseTodoFile(fileName, todos)
- }
- }
-
- // Should never get here
- return fmt.Errorf("Todo %s not found in git-rebase-todo", commit.Sha)
+ return utils.EditRebaseTodo(
+ filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo"), commit.Sha, commit.Action, action)
}
// MoveTodoDown moves a rebase todo item down by one position