mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-04 23:42:10 +03:00
CheckMergeOrRebase calls Refresh already. However, it does an async refresh by default, so we must turn this into a sync refresh so that moving the selection down by one works even for the very first commit in history. Also, we must add an explicit call to FocusLine so that the view selection is in sync with the model selection; previously this was taken care of by the PostRefreshUpdate call that happens as part of a refresh.
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package commit
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Reverts a commit",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.CreateFile("myfile", "myfile content")
|
|
shell.GitAddAll()
|
|
shell.Commit("first commit")
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Commits().
|
|
Focus().
|
|
Lines(
|
|
Contains("first commit"),
|
|
).
|
|
Press(keys.Commits.RevertCommit).
|
|
Tap(func() {
|
|
t.ExpectPopup().Confirmation().
|
|
Title(Equals("Revert commit")).
|
|
Content(MatchesRegexp(`Are you sure you want to revert \w+?`)).
|
|
Confirm()
|
|
}).
|
|
Lines(
|
|
Contains("Revert \"first commit\""),
|
|
Contains("first commit").IsSelected(),
|
|
).
|
|
SelectPreviousItem()
|
|
|
|
t.Views().Main().Content(Contains("-myfile content"))
|
|
t.FileSystem().PathNotPresent("myfile")
|
|
},
|
|
})
|