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",
|
2023-05-21 09:00:29 +02:00
|
|
|
ExtraCmdArgs: []string{},
|
2022-12-19 13:38:32 +02:00
|
|
|
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 02:00:22 +02:00
|
|
|
t.ExpectPopup().Menu().
|
2023-05-25 13:11:51 +02:00
|
|
|
Title(Contains("Reset to other-branch")).
|
|
|
|
Select(Contains("Hard reset")).
|
2022-12-28 01:23:54 +02:00
|
|
|
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
|
|
|
},
|
|
|
|
})
|