2022-12-19 13:38:32 +02:00
|
|
|
package branch
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Reset = NewIntegrationTest(NewIntegrationTestArgs{
|
|
|
|
Description: "Hard reset to another branch",
|
|
|
|
ExtraCmdArgs: "",
|
|
|
|
Skip: false,
|
|
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
|
|
SetupRepo: func(shell *Shell) {
|
|
|
|
shell.NewBranch("current-branch")
|
|
|
|
shell.EmptyCommit("root commit")
|
|
|
|
|
|
|
|
shell.NewBranch("other-branch")
|
|
|
|
shell.EmptyCommit("other-branch commit")
|
|
|
|
|
|
|
|
shell.Checkout("current-branch")
|
|
|
|
shell.EmptyCommit("current-branch commit")
|
|
|
|
},
|
2022-12-27 12:47:37 +02:00
|
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Commits().Lines(
|
2022-12-25 02:38:00 +02:00
|
|
|
Contains("current-branch commit"),
|
|
|
|
Contains("root commit"),
|
|
|
|
)
|
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Branches().
|
2022-12-27 07:27:36 +02:00
|
|
|
Focus().
|
|
|
|
Lines(
|
2022-12-28 01:23:54 +02:00
|
|
|
Contains("current-branch").IsSelected(),
|
2022-12-27 07:27:36 +02:00
|
|
|
Contains("other-branch"),
|
|
|
|
).
|
|
|
|
SelectNextItem().
|
|
|
|
Press(keys.Commits.ViewResetOptions)
|
2022-12-19 13:38:32 +02:00
|
|
|
|
2022-12-28 01:23:54 +02:00
|
|
|
t.ExpectMenu().
|
|
|
|
Title(Contains("reset to other-branch")).
|
|
|
|
Select(Contains("hard reset")).
|
|
|
|
Confirm()
|
2022-12-19 13:38:32 +02:00
|
|
|
|
|
|
|
// assert that we now have the expected commits in the commit panel
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Commits().
|
2022-12-27 07:27:36 +02:00
|
|
|
Lines(
|
|
|
|
Contains("other-branch commit"),
|
|
|
|
Contains("root commit"),
|
|
|
|
)
|
2022-12-19 13:38:32 +02:00
|
|
|
},
|
|
|
|
})
|