summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-04-05 13:03:50 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-04-29 07:28:33 +0200
commitd50c58b4c669b1de94bf4d04f508b3eb5b84647c (patch)
tree32b0692ca3cdd5f41da46494ab31b1bde630ee86
parent5645a662de36bd742c36f26b34b9e74510ba54eb (diff)
Implement "edit commit" in terms of the new EditRebase function
-rw-r--r--pkg/commands/git_commands/rebase.go14
-rw-r--r--pkg/gui/controllers/local_commits_controller.go2
-rw-r--r--pkg/integration/tests/interactive_rebase/drop_todo_commit_with_update_ref.go13
3 files changed, 3 insertions, 26 deletions
diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go
index b34f8886a..26c0536e9 100644
--- a/pkg/commands/git_commands/rebase.go
+++ b/pkg/commands/git_commands/rebase.go
@@ -127,20 +127,6 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, index in
}).Run()
}
-func (self *RebaseCommands) InteractiveRebaseBreakAfter(commits []*models.Commit, index int) error {
- todo, sha, err := self.BuildSingleActionTodo(commits, index-1, "pick")
- if err != nil {
- return err
- }
-
- todo = append(todo, TodoLine{Action: "break", Commit: nil})
- return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
- baseShaOrRoot: sha,
- todoLines: todo,
- overrideEditor: true,
- }).Run()
-}
-
func (self *RebaseCommands) EditRebase(branchRef string) error {
commands := []TodoLine{{Action: "break"}}
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go
index 35e314357..1d05385c9 100644
--- a/pkg/gui/controllers/local_commits_controller.go
+++ b/pkg/gui/controllers/local_commits_controller.go
@@ -301,7 +301,7 @@ func (self *LocalCommitsController) edit(commit *models.Commit) error {
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error {
self.c.LogAction(self.c.Tr.Actions.EditCommit)
- err := self.git.Rebase.InteractiveRebaseBreakAfter(self.model.Commits, self.context().GetSelectedLineIdx())
+ err := self.git.Rebase.EditRebase(commit.Sha)
return self.helpers.MergeAndRebase.CheckMergeOrRebase(err)
})
}
diff --git a/pkg/integration/tests/interactive_rebase/drop_todo_commit_with_update_ref.go b/pkg/integration/tests/interactive_rebase/drop_todo_commit_with_update_ref.go
index c247f1743..fcbf1abe5 100644
--- a/pkg/integration/tests/interactive_rebase/drop_todo_commit_with_update_ref.go
+++ b/pkg/integration/tests/interactive_rebase/drop_todo_commit_with_update_ref.go
@@ -30,17 +30,8 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
- // Once "e" is fixed we can just hit "e", but for now we need to
- // manually do a command-line rebase
- // NavigateToLine(Contains("commit 01")).
- // Press(keys.Universal.Edit).
- Tap(func() {
- t.GlobalPress(keys.Universal.ExecuteCustomCommand)
- t.ExpectPopup().Prompt().
- Title(Equals("Custom Command:")).
- Type(`git -c core.editor="perl -i -lpe 'print \"break\" if $.==1'" rebase -i HEAD~5`).
- Confirm()
- }).
+ NavigateToLine(Contains("commit 01")).
+ Press(keys.Universal.Edit).
Focus().
Lines(
Contains("pick").Contains("(*) commit 06"),