mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-04 23:42:10 +03:00
Keep the same commit selected, by moving the selection down by the number of cherry-picked commits. We also do this when reverting commits, and it is possible now that we use a sync waiting status. We also need to turn the refresh that happens as part of CheckMergeOrRebase into a sync one, so that the commits list is up to date and the new selection isn't clamped.
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package reflog
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Cherry pick a reflog commit",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.EmptyCommit("one")
|
|
shell.EmptyCommit("two")
|
|
shell.EmptyCommit("three")
|
|
shell.HardReset("HEAD^^")
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().ReflogCommits().
|
|
Focus().
|
|
Lines(
|
|
Contains("reset: moving to HEAD^^").IsSelected(),
|
|
Contains("commit: three"),
|
|
Contains("commit: two"),
|
|
Contains("commit (initial): one"),
|
|
).
|
|
SelectNextItem().
|
|
Press(keys.Commits.CherryPickCopy)
|
|
|
|
t.Views().Information().Content(Contains("1 commit copied"))
|
|
|
|
t.Views().Commits().
|
|
Focus().
|
|
Lines(
|
|
Contains("one").IsSelected(),
|
|
).
|
|
Press(keys.Commits.PasteCommits).
|
|
Tap(func() {
|
|
t.ExpectPopup().Alert().
|
|
Title(Equals("Cherry-pick")).
|
|
Content(Contains("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")).
|
|
Confirm()
|
|
}).
|
|
Lines(
|
|
Contains("three"),
|
|
Contains("one").IsSelected(),
|
|
)
|
|
},
|
|
})
|