1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-03 13:21:56 +02:00

migrate revert merge test

This commit is contained in:
Jesse Duffield 2023-02-19 14:47:07 +11:00
parent 88c76868ba
commit b5e325b0a4
43 changed files with 68 additions and 98 deletions

View File

@ -36,6 +36,18 @@ func (self *MenuDriver) Select(option *matcher) *MenuDriver {
return self
}
func (self *MenuDriver) Lines(matchers ...*matcher) *MenuDriver {
self.getViewDriver().Lines(matchers...)
return self
}
func (self *MenuDriver) TopLines(matchers ...*matcher) *MenuDriver {
self.getViewDriver().TopLines(matchers...)
return self
}
func (self *MenuDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedTitle {
self.t.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")

View File

@ -116,6 +116,10 @@ func (self *Shell) Merge(name string) *Shell {
return self.RunCommand("git merge --commit --no-ff " + name)
}
func (self *Shell) ContinueMerge() *Shell {
return self.RunCommand("git -c core.editor=true merge --continue")
}
func (self *Shell) GitAdd(path string) *Shell {
return self.RunCommand(fmt.Sprintf("git add \"%s\"", path))
}

View File

@ -0,0 +1,43 @@
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
)
var RevertMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reverts a merge commit and chooses to revert to the parent commit",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shared.CreateMergeCommit(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().Focus().
TopLines(
Contains("Merge branch 'second-change-branch' into first-change-branch").IsSelected(),
).
Press(keys.Commits.RevertCommit)
t.ExpectPopup().Menu().
Title(Equals("Select parent commit for merge")).
Lines(
Contains("first change"),
Contains("second-change-branch unrelated change"),
Contains("cancel"),
).
Select(Contains("first change")).
Confirm()
t.Views().Commits().IsFocused().
TopLines(
Contains("Revert \"Merge branch 'second-change-branch' into first-change-branch\""),
Contains("Merge branch 'second-change-branch' into first-change-branch").IsSelected(),
).
SelectPreviousItem()
t.Views().Main().Content(Contains("-Second Change").Contains("+First Change"))
},
})

View File

@ -47,3 +47,11 @@ var MergeConflictsSetup = func(shell *Shell) {
EmptyCommit("second-change-branch unrelated change").
Checkout("first-change-branch")
}
var CreateMergeCommit = func(shell *Shell) {
MergeConflictsSetup(shell)
shell.RunShellCommandExpectError("git merge --no-edit second-change-branch")
shell.UpdateFileAndAdd("file", SecondChangeFileContent)
shell.ContinueMerge()
}

View File

@ -40,6 +40,7 @@ var tests = []*components.IntegrationTest{
commit.DiscardOldFileChange,
commit.NewBranch,
commit.Revert,
commit.RevertMerge,
commit.StageRangeOfLines,
commit.Staged,
commit.StagedWithoutHooks,

View File

@ -1 +0,0 @@
ref: refs/heads/other

View File

@ -1 +0,0 @@
e5265503c8aea2860fc4754c1025e4597530ce0e

View File

@ -1,10 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[user]
email = CI@example.com
name = CI

View File

@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.

View File

@ -1,7 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store

View File

@ -1,12 +0,0 @@
0000000000000000000000000000000000000000 d3b35176a575d48743900b1f0863cefbc198f84c CI <CI@example.com> 1622875852 +1000 commit (initial): test 1
d3b35176a575d48743900b1f0863cefbc198f84c d3b35176a575d48743900b1f0863cefbc198f84c CI <CI@example.com> 1622875853 +1000 checkout: moving from master to other
d3b35176a575d48743900b1f0863cefbc198f84c 3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 CI <CI@example.com> 1622875853 +1000 commit: test 2
3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 CI <CI@example.com> 1622875853 +1000 checkout: moving from other to another
3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 1e7d643e0db24ebee10f92aa2f8099d50dbe0f0f CI <CI@example.com> 1622875853 +1000 commit: test 3
1e7d643e0db24ebee10f92aa2f8099d50dbe0f0f 3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 CI <CI@example.com> 1622875853 +1000 checkout: moving from another to other
3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 fa0b6bf64815f57729716334319596c926b6564a CI <CI@example.com> 1622875853 +1000 commit: test 4
fa0b6bf64815f57729716334319596c926b6564a ba4581dc53b5b2ff56803651dfd79245203d546b CI <CI@example.com> 1622875853 +1000 merge another: Merge made by the 'recursive' strategy.
ba4581dc53b5b2ff56803651dfd79245203d546b a4942a576eec3a1a15fb790c942b6860331bee32 CI <CI@example.com> 1622875853 +1000 commit: test 5
a4942a576eec3a1a15fb790c942b6860331bee32 e5265503c8aea2860fc4754c1025e4597530ce0e CI <CI@example.com> 1622875856 +1000 revert: Revert "Merge branch 'another' into other"
e5265503c8aea2860fc4754c1025e4597530ce0e a4942a576eec3a1a15fb790c942b6860331bee32 CI <CI@example.com> 1622875860 +1000 reset: moving to a4942a576eec3a1a15fb790c942b6860331bee32
a4942a576eec3a1a15fb790c942b6860331bee32 ddad764e9e78b555cd41e5e81f8ce969cfa3972c CI <CI@example.com> 1622875862 +1000 commit: test

View File

@ -1,2 +0,0 @@
0000000000000000000000000000000000000000 3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 CI <CI@example.com> 1622875853 +1000 branch: Created from HEAD
3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 1e7d643e0db24ebee10f92aa2f8099d50dbe0f0f CI <CI@example.com> 1622875853 +1000 commit: test 3

View File

@ -1 +0,0 @@
0000000000000000000000000000000000000000 d3b35176a575d48743900b1f0863cefbc198f84c CI <CI@example.com> 1622875852 +1000 commit (initial): test 1

View File

@ -1,8 +0,0 @@
0000000000000000000000000000000000000000 d3b35176a575d48743900b1f0863cefbc198f84c CI <CI@example.com> 1622875853 +1000 branch: Created from HEAD
d3b35176a575d48743900b1f0863cefbc198f84c 3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 CI <CI@example.com> 1622875853 +1000 commit: test 2
3c3594b2fd655fb7ffe36077ee8a9c3f79fb5fc6 fa0b6bf64815f57729716334319596c926b6564a CI <CI@example.com> 1622875853 +1000 commit: test 4
fa0b6bf64815f57729716334319596c926b6564a ba4581dc53b5b2ff56803651dfd79245203d546b CI <CI@example.com> 1622875853 +1000 merge another: Merge made by the 'recursive' strategy.
ba4581dc53b5b2ff56803651dfd79245203d546b a4942a576eec3a1a15fb790c942b6860331bee32 CI <CI@example.com> 1622875853 +1000 commit: test 5
a4942a576eec3a1a15fb790c942b6860331bee32 e5265503c8aea2860fc4754c1025e4597530ce0e CI <CI@example.com> 1622875856 +1000 revert: Revert "Merge branch 'another' into other"
e5265503c8aea2860fc4754c1025e4597530ce0e a4942a576eec3a1a15fb790c942b6860331bee32 CI <CI@example.com> 1622875860 +1000 reset: moving to a4942a576eec3a1a15fb790c942b6860331bee32
a4942a576eec3a1a15fb790c942b6860331bee32 ddad764e9e78b555cd41e5e81f8ce969cfa3972c CI <CI@example.com> 1622875862 +1000 commit: test

View File

@ -1,2 +0,0 @@
x�ŽK
1]罤әÎDWsŒtÒƒ‚q†1‚Ç7GpóEQ¼²¶öè`“;ô]DY&/cIe¬(ù`±f*š´R š-ïúê yâhka',´,ì#:϶.5$š˜ÐUA“?ý¾îp›á|›¯úÍm{ꩬíÖÅÀ‘-"šAÇ©®ê¦ë»›Ð)9Ñ

View File

@ -1,2 +0,0 @@
x�ÎM
1 @a×=E÷‚$mÓf5ÇHcŠ‚u†±‚ÇwŽàöã-ž,½?†Å‚‡±©Z!nÁ·(‚7B­Õs À‡D…(`˘J³ò¦¯a9”à˜RTÏÈH­¦²k�9‚÷XU½3ü÷e³ÓlÏÓ|Õ/÷õ©'YúÅbt.'ÊÑÙ#€ÙuŸúgn†¾‡ùÿ8ê

View File

@ -1 +0,0 @@
x�PΛjΓ0μY_±δ’CKΠkW”RΘ)‡^J`%―bCmY-ύό�τz†y1e�穃#ύΠ›δκ]¥RΜ€Frv�}ΤΪω€ Ρ›MH©¨7Y:°Oή2)� ¬9$]v6S$ν�Ι"Ξ*ώκγΪΰ|�ησεU~xΎ}Κ©¬σ ²6�Hπh΄ΦjgχQ]ώ)Wος-­ΓαMΪU 7^ΚG^Φ>J;Β΄τξψ ΤΗ8mΠξ† ώ� ³Ηh†‚.c¶µ"EνΝP‡�¬G«έ€�ςΣ�q›–«*#/WΩ`ζA`Ο―¬3εJ>ξ`6CΞyg&*ΙR&$Ο'υ Ήl'

View File

@ -1 +0,0 @@
1e7d643e0db24ebee10f92aa2f8099d50dbe0f0f

View File

@ -1 +0,0 @@
d3b35176a575d48743900b1f0863cefbc198f84c

View File

@ -1 +0,0 @@
ddad764e9e78b555cd41e5e81f8ce969cfa3972c

View File

@ -1 +0,0 @@
{"KeyEvents":[{"Timestamp":1730,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2002,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2305,"Mod":0,"Key":258,"Ch":0},{"Timestamp":2968,"Mod":0,"Key":256,"Ch":116},{"Timestamp":3402,"Mod":0,"Key":13,"Ch":13},{"Timestamp":3985,"Mod":0,"Key":257,"Ch":0},{"Timestamp":4304,"Mod":0,"Key":257,"Ch":0},{"Timestamp":5850,"Mod":0,"Key":258,"Ch":0},{"Timestamp":6785,"Mod":0,"Key":256,"Ch":103},{"Timestamp":7441,"Mod":0,"Key":13,"Ch":13},{"Timestamp":7978,"Mod":0,"Key":260,"Ch":0},{"Timestamp":8304,"Mod":0,"Key":260,"Ch":0},{"Timestamp":8585,"Mod":0,"Key":256,"Ch":99},{"Timestamp":8816,"Mod":0,"Key":256,"Ch":116},{"Timestamp":8873,"Mod":0,"Key":256,"Ch":101},{"Timestamp":9041,"Mod":0,"Key":256,"Ch":115},{"Timestamp":9081,"Mod":0,"Key":256,"Ch":116},{"Timestamp":9416,"Mod":0,"Key":13,"Ch":13},{"Timestamp":11041,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":135,"Height":74}]}

View File

@ -1,40 +0,0 @@
#!/bin/sh
set -e
cd $1
git init
git config user.email "CI@example.com"
git config user.name "CI"
git checkout -b master
echo "test" > file1
git add .
git commit -m "test 1"
git checkout -b other
echo "test" > file2
git add .
git commit -m "test 2"
git checkout -b another
echo "test" > file3
git add .
git commit -m "test 3"
git checkout other
echo "test" > file4
git add .
git commit -m "test 4"
git merge another
echo "test" > file5
git add .
git commit -m "test 5"

View File

@ -1 +0,0 @@
{ "description": "In this test we revert a merge conflict, choosing which parent we want to retain... or something like that. We need to rename the newly created commit so that we don't fail on the snapshot comparison", "speed": 10 }