From d50c58b4c669b1de94bf4d04f508b3eb5b84647c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 5 Apr 2023 13:03:50 +0200 Subject: [PATCH] Implement "edit commit" in terms of the new EditRebase function --- pkg/commands/git_commands/rebase.go | 14 -------------- pkg/gui/controllers/local_commits_controller.go | 2 +- .../drop_todo_commit_with_update_ref.go | 13 ++----------- 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"),