mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Suspend lazygit when continuing a rebase with exec todos
It's likely that the exec todos are some kind of lengthy build task whose output the user will want to see in the terminal.
This commit is contained in:
@ -9,10 +9,12 @@ import (
|
|||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
|
"github.com/stefanhaller/git-todo-parser/todo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MergeAndRebaseHelper struct {
|
type MergeAndRebaseHelper struct {
|
||||||
@ -110,7 +112,12 @@ func (self *MergeAndRebaseHelper) genericMergeCommand(command string) error {
|
|||||||
// we should end up with a command like 'git merge --continue'
|
// we should end up with a command like 'git merge --continue'
|
||||||
|
|
||||||
// it's impossible for a rebase to require a commit so we'll use a subprocess only if it's a merge
|
// it's impossible for a rebase to require a commit so we'll use a subprocess only if it's a merge
|
||||||
if status == enums.REBASE_MODE_MERGING && command != REBASE_OPTION_ABORT && self.c.UserConfig.Git.Merging.ManualCommit {
|
needsSubprocess := (status == enums.REBASE_MODE_MERGING && command != REBASE_OPTION_ABORT && self.c.UserConfig.Git.Merging.ManualCommit) ||
|
||||||
|
// but we'll also use a subprocess if we have exec todos; those are likely to be lengthy build
|
||||||
|
// tasks whose output the user will want to see in the terminal
|
||||||
|
(status == enums.REBASE_MODE_REBASING && command != REBASE_OPTION_ABORT && self.hasExecTodos())
|
||||||
|
|
||||||
|
if needsSubprocess {
|
||||||
// TODO: see if we should be calling more of the code from self.Git.Rebase.GenericMergeOrRebaseAction
|
// TODO: see if we should be calling more of the code from self.Git.Rebase.GenericMergeOrRebaseAction
|
||||||
return self.c.RunSubprocessAndRefresh(
|
return self.c.RunSubprocessAndRefresh(
|
||||||
self.c.Git().Rebase.GenericMergeOrRebaseActionCmdObj(commandType, command),
|
self.c.Git().Rebase.GenericMergeOrRebaseActionCmdObj(commandType, command),
|
||||||
@ -123,6 +130,18 @@ func (self *MergeAndRebaseHelper) genericMergeCommand(command string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *MergeAndRebaseHelper) hasExecTodos() bool {
|
||||||
|
for _, commit := range self.c.Model().Commits {
|
||||||
|
if commit.Status != models.StatusRebasing {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if commit.Action == todo.Exec {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var conflictStrings = []string{
|
var conflictStrings = []string{
|
||||||
"Failed to merge in the changes",
|
"Failed to merge in the changes",
|
||||||
"When you have resolved this problem",
|
"When you have resolved this problem",
|
||||||
|
@ -38,7 +38,7 @@ var ShowExecTodos = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
).
|
).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
t.Common().ContinueRebase()
|
t.Common().ContinueRebase()
|
||||||
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("Rebasing (4/4)Executing: false")).Confirm()
|
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("exit status 1")).Confirm()
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("CI ◯ <-- YOU ARE HERE --- commit 03"),
|
Contains("CI ◯ <-- YOU ARE HERE --- commit 03"),
|
||||||
|
Reference in New Issue
Block a user