1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
func setupForAmendTests(shell *Shell) {
shell.EmptyCommit("base commit")
shell.NewBranch("branch")
shell.Checkout("master")
shell.CreateFileAndAdd("file1", "master")
shell.Commit("file1 changed in master")
shell.Checkout("branch")
shell.UpdateFileAndAdd("file2", "two")
shell.Commit("commit two")
shell.CreateFileAndAdd("file1", "branch")
shell.Commit("file1 changed in branch")
shell.UpdateFileAndAdd("file3", "three")
shell.Commit("commit three")
}
func doTheRebaseForAmendTests(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit three").IsSelected(),
Contains("file1 changed in branch"),
Contains("commit two"),
Contains("base commit"),
)
t.Views().Branches().
Focus().
NavigateToLine(Contains("master")).
Press(keys.Branches.RebaseBranch).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Rebase 'branch'")).
Select(Contains("Simple rebase")).
Confirm()
t.Common().AcknowledgeConflicts()
})
t.Views().Commits().
Lines(
Contains("--- Pending rebase todos ---"),
Contains("pick").Contains("commit three"),
Contains("pick").Contains("<-- CONFLICT --- file1 changed in branch"),
Contains("--- Commits ---"),
Contains("commit two"),
Contains("file1 changed in master"),
Contains("base commit"),
)
t.Views().Files().
Focus().
PressEnter()
t.Views().MergeConflicts().
IsFocused().
SelectNextItem(). // choose "incoming"
PressPrimaryAction()
t.ExpectPopup().Confirmation().
Title(Equals("Continue")).
Content(Contains("All merge conflicts resolved. Continue the rebase?")).
Cancel()
}
func checkCommitContainsChange(t *TestDriver, commitSubject string, change string) {
t.Views().Commits().
Focus().
NavigateToLine(Contains(commitSubject))
t.Views().Main().
Content(Contains(change))
}
func checkBlockingHook(t *TestDriver, keys config.KeybindingConfig) {
// Shared function for tests using the blockingHook pre-commit hook for testing hook skipping
// Stage first file
t.Views().Files().
IsFocused().
PressPrimaryAction().
Press(keys.Files.CommitChanges)
// Try to commit with hook
t.ExpectPopup().CommitMessagePanel().
Title(Equals("Commit summary")).
Type("Commit should fail").
Confirm()
t.ExpectPopup().Alert().
Title(Equals("Error")).
Content(Contains("Git command failed.")).
Confirm()
// Clear the message
t.Views().Files().
IsFocused().
Press(keys.Files.CommitChanges)
t.ExpectPopup().CommitMessagePanel().
Title(Equals("Commit summary")).
Clear().
Cancel()
// Unstage the file
t.Views().Files().
IsFocused().
PressPrimaryAction()
}
|