1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

Show "exec" todos in the list of rebase todos

Unfortunately it isn't possible to delete them. This would often be useful, but
our todo rewriting mechanisms rely on being able to find todos by some
identifier (hash for pick, ref for update-ref), and exec todos don't have a
unique identifier.
This commit is contained in:
Stefan Haller
2024-06-12 11:17:39 +02:00
parent 906d21f3ce
commit 899e25b208
5 changed files with 65 additions and 0 deletions

View File

@ -344,6 +344,8 @@ func (self *CommitLoader) getRebasingCommits(rebaseMode enums.RebaseMode) []*mod
for _, t := range todos { for _, t := range todos {
if t.Command == todo.UpdateRef { if t.Command == todo.UpdateRef {
t.Msg = t.Ref t.Msg = t.Ref
} else if t.Command == todo.Exec {
t.Msg = t.ExecCommand
} else if t.Commit == "" { } else if t.Commit == "" {
// Command does not have a commit associated, skip // Command does not have a commit associated, skip
continue continue

View File

@ -284,6 +284,9 @@ func (self *LocalCommitsController) GetOnRenderToMain() func() error {
map[string]string{ map[string]string{
"ref": strings.TrimPrefix(commit.Name, "refs/heads/"), "ref": strings.TrimPrefix(commit.Name, "refs/heads/"),
})) }))
} else if commit.Action == todo.Exec {
task = types.NewRenderStringTask(
self.c.Tr.ExecCommandHere + "\n\n" + commit.Name)
} else { } else {
cmdObj := self.c.Git().Commit.ShowCmdObj(commit.Hash, self.c.Modes().Filtering.GetPath()) cmdObj := self.c.Git().Commit.ShowCmdObj(commit.Hash, self.c.Modes().Filtering.GetPath())
task = types.NewRunPtyTask(cmdObj.GetCmd()) task = types.NewRunPtyTask(cmdObj.GetCmd())

View File

@ -164,6 +164,7 @@ type TranslationSet struct {
RewordCommitEditor string RewordCommitEditor string
NoCommitsThisBranch string NoCommitsThisBranch string
UpdateRefHere string UpdateRefHere string
ExecCommandHere string
Error string Error string
Undo string Undo string
UndoReflog string UndoReflog string
@ -1093,6 +1094,7 @@ func EnglishTranslationSet() TranslationSet {
SquashTooltip: "Squash the selected commit into the commit below it. The selected commit's message will be appended to the commit below it.", SquashTooltip: "Squash the selected commit into the commit below it. The selected commit's message will be appended to the commit below it.",
NoCommitsThisBranch: "No commits for this branch", NoCommitsThisBranch: "No commits for this branch",
UpdateRefHere: "Update branch '{{.ref}}' here", UpdateRefHere: "Update branch '{{.ref}}' here",
ExecCommandHere: "Execute the following command here:",
CannotSquashOrFixupFirstCommit: "There's no commit below to squash into", CannotSquashOrFixupFirstCommit: "There's no commit below to squash into",
Fixup: "Fixup", Fixup: "Fixup",
SureFixupThisCommit: "Are you sure you want to 'fixup' the selected commit(s) into the commit below?", SureFixupThisCommit: "Are you sure you want to 'fixup' the selected commit(s) into the commit below?",

View File

@ -0,0 +1,57 @@
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ShowExecTodos = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Show exec todos in the rebase todo list",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
cfg.UserConfig.CustomCommands = []config.CustomCommand{
{
Key: "X",
Context: "commits",
Command: "git -c core.editor=: rebase -i -x false HEAD^^",
},
}
},
SetupRepo: func(shell *Shell) {
shell.
NewBranch("branch1").
CreateNCommits(3)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Press("X").
Tap(func() {
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("Rebasing (2/4)Executing: false")).Confirm()
}).
Lines(
Contains("exec").Contains("false"),
Contains("pick").Contains("CI commit 03"),
Contains("CI ◯ <-- YOU ARE HERE --- commit 02"),
Contains("CI ◯ commit 01"),
).
Tap(func() {
t.Common().ContinueRebase()
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("Rebasing (4/4)Executing: false")).Confirm()
}).
Lines(
Contains("CI ◯ <-- YOU ARE HERE --- commit 03"),
Contains("CI ◯ commit 02"),
Contains("CI ◯ commit 01"),
).
Tap(func() {
t.Common().ContinueRebase()
}).
Lines(
Contains("CI ◯ commit 03"),
Contains("CI ◯ commit 02"),
Contains("CI ◯ commit 01"),
)
},
})

View File

@ -209,6 +209,7 @@ var tests = []*components.IntegrationTest{
interactive_rebase.RewordLastCommit, interactive_rebase.RewordLastCommit,
interactive_rebase.RewordYouAreHereCommit, interactive_rebase.RewordYouAreHereCommit,
interactive_rebase.RewordYouAreHereCommitWithEditor, interactive_rebase.RewordYouAreHereCommitWithEditor,
interactive_rebase.ShowExecTodos,
interactive_rebase.SquashDownFirstCommit, interactive_rebase.SquashDownFirstCommit,
interactive_rebase.SquashDownSecondCommit, interactive_rebase.SquashDownSecondCommit,
interactive_rebase.SquashFixupsAbove, interactive_rebase.SquashFixupsAbove,