mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-21 12:16:54 +02:00
For non-merge commits we change "pick" to "drop" when we delete them. We do this so that we can use the same code for dropping a commit no matter whether we are in an interactive rebase or not. (If we aren't, we could just as well delete the pick line from the todo list instead of setting it to "drop", but if we are, it is better to keep the line around so that the user can change it back to "pick" if they change their mind.) However, merge commits can't be changed to "drop", so we have to delete them from the todo file. We add a new daemon instruction that does this. We still don't allow deleting a merge commit from within an interactive rebase. The reason is that we don't show the "label" and "reset" todos in lazygit, so deleting a merge commit would leave the commits from the branch that is being merged in the list as "pick" commits, with no indication that they are going to be dropped because they are on a different branch, and the merge commit that would have brought them in is gone. This could be very confusing.
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
package interactive_rebase
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
|
|
)
|
|
|
|
var DropMergeCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Drops a merge commit outside of an interactive rebase",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
GitVersion: AtLeast("2.22.0"), // first version that supports the --rebase-merges option
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
SetupRepo: func(shell *Shell) {
|
|
shared.CreateMergeCommit(shell)
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Commits().
|
|
Focus().
|
|
Lines(
|
|
Contains("CI ⏣─╮ Merge branch 'second-change-branch' into first-change-branch").IsSelected(),
|
|
Contains("CI │ ◯ * second-change-branch unrelated change"),
|
|
Contains("CI │ ◯ second change"),
|
|
Contains("CI ◯ │ first change"),
|
|
Contains("CI ◯─╯ * original"),
|
|
Contains("CI ◯ three"),
|
|
Contains("CI ◯ two"),
|
|
Contains("CI ◯ one"),
|
|
).
|
|
Press(keys.Universal.Remove).
|
|
Tap(func() {
|
|
t.ExpectPopup().Confirmation().
|
|
Title(Equals("Drop commit")).
|
|
Content(Equals("Are you sure you want to drop the selected merge commit? Note that it will also drop all the commits that were merged in by it.")).
|
|
Confirm()
|
|
}).
|
|
Lines(
|
|
Contains("CI ◯ first change").IsSelected(),
|
|
Contains("CI ◯ * original"),
|
|
Contains("CI ◯ three"),
|
|
Contains("CI ◯ two"),
|
|
Contains("CI ◯ one"),
|
|
)
|
|
},
|
|
})
|