1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

Add rebase from marked base commit test

This also fixes a bug where after the rebase each commit in the commits view had a tick against it because we hadn't
refreshed the view since the base commit was no longer marked
This commit is contained in:
Jesse Duffield
2023-08-12 13:17:01 +10:00
parent 3ea81d4a6f
commit f1753f36c8
7 changed files with 385 additions and 14 deletions

View File

@ -40,12 +40,12 @@ var RebaseFromMarkedBase = NewIntegrationTest(NewIntegrationTestArgs{
NavigateToLine(Contains("active one")).
Press(keys.Commits.MarkCommitAsBaseForRebase).
Lines(
Contains("active three"),
Contains("active two"),
Contains("active three").Contains("✓"),
Contains("active two").Contains("✓"),
Contains("↑↑↑ Will rebase from here ↑↑↑ active one"),
Contains("three"),
Contains("two"),
Contains("one"),
Contains("three").DoesNotContain("✓"),
Contains("two").DoesNotContain("✓"),
Contains("one").DoesNotContain("✓"),
)
t.Views().Information().Content(Contains("Marked a base commit for rebase"))
@ -66,13 +66,13 @@ var RebaseFromMarkedBase = NewIntegrationTest(NewIntegrationTestArgs{
Confirm()
t.Views().Commits().Lines(
Contains("active three"),
Contains("active two"),
Contains("target two"),
Contains("target one"),
Contains("three"),
Contains("two"),
Contains("one"),
Contains("active three").DoesNotContain("✓"),
Contains("active two").DoesNotContain("✓"),
Contains("target two").DoesNotContain("✓"),
Contains("target one").DoesNotContain("✓"),
Contains("three").DoesNotContain("✓"),
Contains("two").DoesNotContain("✓"),
Contains("one").DoesNotContain("✓"),
)
},
})

View File

@ -0,0 +1,81 @@
package demo
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var RebaseOnto = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rebase with '--onto' flag. We start with a feature branch on the develop branch that we want to rebase onto the master branch",
ExtraCmdArgs: []string{},
Skip: false,
IsDemo: true,
SetupConfig: func(config *config.AppConfig) {
config.UserConfig.Gui.NerdFontsVersion = "3"
},
SetupRepo: func(shell *Shell) {
shell.CreateNCommitsWithRandomMessages(60)
shell.NewBranch("develop")
shell.SetAuthor("Joe Blow", "joeblow@gmail.com")
shell.RandomChangeCommit("Develop commit 1")
shell.RandomChangeCommit("Develop commit 2")
shell.RandomChangeCommit("Develop commit 3")
shell.SetAuthor("Jesse Duffield", "jesseduffield@gmail.com")
shell.NewBranch("feature/demo")
shell.RandomChangeCommit("Feature commit 1")
shell.RandomChangeCommit("Feature commit 2")
shell.RandomChangeCommit("Feature commit 3")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("feature/demo", "origin/feature/demo")
shell.SetBranchUpstream("develop", "origin/develop")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.SetCaptionPrefix("Rebase from marked base commit")
t.Wait(1000)
// first we focus the commits view, then expand to show the branches against each commit
// Then we go back to normal value, mark the last develop branch commit as the marked commit
// Then go to the branches view and press 'r' on the master branch to rebase onto it
// then we force push our changes.
t.Views().Commits().
Focus().
Press(keys.Universal.PrevScreenMode).
Wait(500).
NavigateToLine(Contains("Develop commit 3")).
Wait(500).
Press(keys.Commits.MarkCommitAsBaseForRebase).
Wait(1000).
Press(keys.Universal.NextScreenMode).
Wait(500)
t.Views().Branches().
Focus().
Wait(500).
NavigateToLine(Contains("master")).
Wait(500).
Press(keys.Branches.RebaseBranch).
Tap(func() {
t.ExpectPopup().Menu().
Title(Contains("Rebase 'feature/demo' from marked base onto 'master'")).
Select(Contains("Simple rebase")).
Confirm()
}).
Wait(1000).
Press(keys.Universal.Push).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Contains("Force push")).
Content(AnyString()).
Wait(500).
Confirm()
})
},
})

View File

@ -98,6 +98,7 @@ var tests = []*components.IntegrationTest{
demo.Filter,
demo.InteractiveRebase,
demo.NukeWorkingTree,
demo.RebaseOnto,
demo.StageLines,
demo.Undo,
demo.WorktreeCreateFromBranches,