mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-10 20:05:50 +02:00
Add test for a special situation in rebases involving empty commits
The situation is that you perform a rebase, and one of the commits becomes empty during the rebase, in a way that couldn't be predicted before the rebase started. To explain: git rebase has some logic where it immediately discards commits if it can tell that they already exist in the branch being rebased onto; it does this by looking at the patch ids of the commits to work out which commits already exist upstream. But for those commits that become empty even though there isn't a corresponding commit upstream, git stops with an error, and lazygit detects this (in CheckMergeOrRebaseWithRefreshOptions) and automatically continues the rebase. This all works fine; I'm adding this test because I almost broke this during development of this branch, so I'm adding it to guard against regressions.
This commit is contained in:
parent
b210b4363d
commit
e1eb95b2b3
2 changed files with 46 additions and 0 deletions
|
@ -0,0 +1,45 @@
|
|||
package interactive_rebase
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var RebaseWithCommitThatBecomesEmpty = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Performs a rebase involving a commit that becomes empty during the rebase, and gets dropped.",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
// It is important that we create two separate commits for the two
|
||||
// changes to the file, but only one commit for the same changes on our
|
||||
// branch; otherwise, the commit would be discarded at the start of the
|
||||
// rebase already.
|
||||
shell.CreateFileAndAdd("file", "change 1\n")
|
||||
shell.Commit("master change 1")
|
||||
shell.UpdateFileAndAdd("file", "change 1\nchange 2\n")
|
||||
shell.Commit("master change 2")
|
||||
shell.NewBranchFrom("branch", "HEAD^^")
|
||||
shell.CreateFileAndAdd("file", "change 1\nchange 2\n")
|
||||
shell.Commit("branch change")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
NavigateToLine(Contains("master")).
|
||||
Press(keys.Branches.RebaseBranch)
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Rebase 'branch'")).
|
||||
Select(Contains("Simple rebase")).
|
||||
Confirm()
|
||||
|
||||
t.Views().Commits().
|
||||
Lines(
|
||||
Contains("master change 2"),
|
||||
Contains("master change 1"),
|
||||
Contains("initial commit"),
|
||||
)
|
||||
},
|
||||
})
|
|
@ -260,6 +260,7 @@ var tests = []*components.IntegrationTest{
|
|||
interactive_rebase.QuickStartKeepSelection,
|
||||
interactive_rebase.QuickStartKeepSelectionRange,
|
||||
interactive_rebase.Rebase,
|
||||
interactive_rebase.RebaseWithCommitThatBecomesEmpty,
|
||||
interactive_rebase.RewordCommitWithEditorAndFail,
|
||||
interactive_rebase.RewordFirstCommit,
|
||||
interactive_rebase.RewordLastCommit,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue