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")
|
|
|
|
},
|
|
|
|
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
|
|
|
input.SwitchToBranchesWindow()
|
|
|
|
assert.CurrentViewName("localBranches")
|
|
|
|
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.SelectedLine(Contains("current-branch"))
|
2022-12-19 13:38:32 +02:00
|
|
|
input.NextItem()
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.SelectedLine(Contains("other-branch"))
|
2022-12-19 13:38:32 +02:00
|
|
|
|
|
|
|
input.PressKeys(keys.Commits.ViewResetOptions)
|
|
|
|
assert.InMenu()
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.CurrentViewTitle(Contains("reset to other-branch"))
|
2022-12-19 13:38:32 +02:00
|
|
|
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.SelectedLine(Contains("soft reset"))
|
2022-12-19 13:38:32 +02:00
|
|
|
input.NextItem()
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.SelectedLine(Contains("mixed reset"))
|
2022-12-19 13:38:32 +02:00
|
|
|
input.NextItem()
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.SelectedLine(Contains("hard reset"))
|
2022-12-19 13:38:32 +02:00
|
|
|
|
|
|
|
input.Confirm()
|
|
|
|
|
|
|
|
// ensure that we've returned from the menu before continuing
|
|
|
|
assert.CurrentViewName("localBranches")
|
|
|
|
|
|
|
|
// assert that we now have the expected commits in the commit panel
|
|
|
|
input.SwitchToCommitsWindow()
|
|
|
|
assert.CurrentViewName("commits")
|
|
|
|
assert.CommitCount(2)
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.SelectedLine(Contains("other-branch commit"))
|
2022-12-19 13:38:32 +02:00
|
|
|
input.NextItem()
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.SelectedLine(Contains("root commit"))
|
2022-12-19 13:38:32 +02:00
|
|
|
},
|
|
|
|
})
|