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

migrate undo test

This commit is contained in:
Jesse Duffield 2023-02-19 15:27:13 +11:00
parent 93b9e1bd19
commit 65bd0ab431
46 changed files with 95 additions and 139 deletions

View File

@ -195,17 +195,17 @@ func (self *UndoController) parseReflogForActions(onUserAction func(counter int,
counter++
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^\[lazygit redo\]`); ok {
counter--
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase -i \(abort\)|^rebase -i \(finish\)`); ok {
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase (-i )?\(abort\)|^rebase (-i )?\(finish\)`); ok {
rebaseFinishCommitSha = reflogCommit.Sha
} else if ok, match := utils.FindStringSubmatch(reflogCommit.Name, `^checkout: moving from ([\S]+) to ([\S]+)`); ok {
action = &reflogAction{kind: CHECKOUT, from: match[1], to: match[2]}
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^commit|^reset: moving to|^pull`); ok {
action = &reflogAction{kind: COMMIT, from: prevCommitSha, to: reflogCommit.Sha}
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase -i \(start\)`); ok {
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase (-i )?\(start\)`); ok {
// if we're here then we must be currently inside an interactive rebase
action = &reflogAction{kind: CURRENT_REBASE, from: prevCommitSha}
}
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase -i \(start\)`); ok {
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase (-i )?\(start\)`); ok {
action = &reflogAction{kind: REBASE, from: prevCommitSha, to: rebaseFinishCommitSha}
rebaseFinishCommitSha = ""
}

View File

@ -20,6 +20,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
"github.com/jesseduffield/lazygit/pkg/integration/tests/submodule"
"github.com/jesseduffield/lazygit/pkg/integration/tests/sync"
"github.com/jesseduffield/lazygit/pkg/integration/tests/undo"
)
var tests = []*components.IntegrationTest{
@ -83,4 +84,5 @@ var tests = []*components.IntegrationTest{
sync.Pull,
sync.PullAndSetUpstream,
sync.RenameBranchAndPull,
undo.UndoDrop,
}

View File

@ -0,0 +1,90 @@
package undo
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var UndoDrop = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Drop some commits and then undo/redo the actions",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.EmptyCommit("three")
shell.EmptyCommit("four")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
confirmCommitDrop := func() {
t.ExpectPopup().Confirmation().
Title(Equals("Delete Commit")).
Content(Equals("Are you sure you want to delete this commit?")).
Confirm()
}
confirmUndo := func() {
t.ExpectPopup().Confirmation().
Title(Equals("Undo")).
Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
Confirm()
}
confirmRedo := func() {
t.ExpectPopup().Confirmation().
Title(Equals("Redo")).
Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
Confirm()
}
t.Views().Commits().Focus().
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
).
Press(keys.Universal.Remove).
Tap(confirmCommitDrop).
Lines(
Contains("three").IsSelected(),
Contains("two"),
Contains("one"),
).
Press(keys.Universal.Remove).
Tap(confirmCommitDrop).
Lines(
Contains("two").IsSelected(),
Contains("one"),
).
Press(keys.Universal.Undo).
Tap(confirmUndo).
Lines(
Contains("three").IsSelected(),
Contains("two"),
Contains("one"),
).
Press(keys.Universal.Undo).
Tap(confirmUndo).
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
).
Press(keys.Universal.Redo).
Tap(confirmRedo).
Lines(
Contains("three").IsSelected(),
Contains("two"),
Contains("one"),
).
Press(keys.Universal.Redo).
Tap(confirmRedo).
Lines(
Contains("two").IsSelected(),
Contains("one"),
)
},
})

View File

@ -1,24 +0,0 @@
# This is a combination of 2 commits.
# This is the 1st commit message:
file4
# This is the commit message #2:
file4
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Tue Apr 6 14:29:30 2021 +1000
#
# interactive rebase in progress; onto 68ac4e4
# Last commands done (2 commands done):
# pick fcf4651 file4
# squash 9d187b7 file4
# No commands remaining.
# You are currently rebasing branch 'branch2' on '68ac4e4'.
#
# Changes to be committed:
# new file: file4
#

View File

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

View File

@ -1 +0,0 @@
7ce8eac65e3ae50cb50a570dc775b745464f3a3e

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,20 +0,0 @@
0000000000000000000000000000000000000000 6d95d7a7842625152ba887482879dfdaf247f591 CI <CI@example.com> 1617683370 +1000 commit (initial): file0
6d95d7a7842625152ba887482879dfdaf247f591 4f77a25a15ccca0273baa522f7281727f31ceeb8 CI <CI@example.com> 1617683370 +1000 commit: file1
4f77a25a15ccca0273baa522f7281727f31ceeb8 68ac4e416c01408d37c59465852aa1856a4abdb1 CI <CI@example.com> 1617683370 +1000 commit: file2
68ac4e416c01408d37c59465852aa1856a4abdb1 fcf46511d7819220e0cc310ae6d891fadfdb79aa CI <CI@example.com> 1617683370 +1000 commit: file4
fcf46511d7819220e0cc310ae6d891fadfdb79aa fcf46511d7819220e0cc310ae6d891fadfdb79aa CI <CI@example.com> 1617683370 +1000 checkout: moving from master to branch2
fcf46511d7819220e0cc310ae6d891fadfdb79aa 5d2b236ff0e8342ef1e531506f6f99070d53cf25 CI <CI@example.com> 1617683370 +1000 commit: file4
5d2b236ff0e8342ef1e531506f6f99070d53cf25 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683370 +1000 commit: file4
3e4f2b1aeb076cff592279f94b1f495442690521 7ce8eac65e3ae50cb50a570dc775b745464f3a3e CI <CI@example.com> 1617683370 +1000 commit: file2
7ce8eac65e3ae50cb50a570dc775b745464f3a3e 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683372 +1000 rebase -i (start): checkout 3e4f2b1aeb076cff592279f94b1f495442690521
3e4f2b1aeb076cff592279f94b1f495442690521 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683372 +1000 rebase -i (finish): returning to refs/heads/branch2
3e4f2b1aeb076cff592279f94b1f495442690521 5d2b236ff0e8342ef1e531506f6f99070d53cf25 CI <CI@example.com> 1617683373 +1000 rebase -i (start): checkout fcf46511d7819220e0cc310ae6d891fadfdb79aa
5d2b236ff0e8342ef1e531506f6f99070d53cf25 9d187b7f4819a69996dd27e3d66a5224e05d9f41 CI <CI@example.com> 1617683373 +1000 rebase -i (fixup): file4
9d187b7f4819a69996dd27e3d66a5224e05d9f41 9d187b7f4819a69996dd27e3d66a5224e05d9f41 CI <CI@example.com> 1617683373 +1000 rebase -i (finish): returning to refs/heads/branch2
9d187b7f4819a69996dd27e3d66a5224e05d9f41 fcf46511d7819220e0cc310ae6d891fadfdb79aa CI <CI@example.com> 1617683374 +1000 rebase -i (start): checkout 68ac4e416c01408d37c59465852aa1856a4abdb1
fcf46511d7819220e0cc310ae6d891fadfdb79aa 9936b8f380c2937bb457ade468bfc7dc850293f9 CI <CI@example.com> 1617683374 +1000 rebase -i (squash): file4
9936b8f380c2937bb457ade468bfc7dc850293f9 9936b8f380c2937bb457ade468bfc7dc850293f9 CI <CI@example.com> 1617683374 +1000 rebase -i (finish): returning to refs/heads/branch2
9936b8f380c2937bb457ade468bfc7dc850293f9 9d187b7f4819a69996dd27e3d66a5224e05d9f41 CI <CI@example.com> 1617683376 +1000 [lazygit undo]: updating HEAD
9d187b7f4819a69996dd27e3d66a5224e05d9f41 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683377 +1000 [lazygit undo]: updating HEAD
3e4f2b1aeb076cff592279f94b1f495442690521 7ce8eac65e3ae50cb50a570dc775b745464f3a3e CI <CI@example.com> 1617683377 +1000 [lazygit undo]: updating HEAD
7ce8eac65e3ae50cb50a570dc775b745464f3a3e 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683379 +1000 [lazygit redo]: updating HEAD

View File

@ -1,11 +0,0 @@
0000000000000000000000000000000000000000 fcf46511d7819220e0cc310ae6d891fadfdb79aa CI <CI@example.com> 1617683370 +1000 branch: Created from HEAD
fcf46511d7819220e0cc310ae6d891fadfdb79aa 5d2b236ff0e8342ef1e531506f6f99070d53cf25 CI <CI@example.com> 1617683370 +1000 commit: file4
5d2b236ff0e8342ef1e531506f6f99070d53cf25 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683370 +1000 commit: file4
3e4f2b1aeb076cff592279f94b1f495442690521 7ce8eac65e3ae50cb50a570dc775b745464f3a3e CI <CI@example.com> 1617683370 +1000 commit: file2
7ce8eac65e3ae50cb50a570dc775b745464f3a3e 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683372 +1000 rebase -i (finish): refs/heads/branch2 onto 3e4f2b1aeb076cff592279f94b1f495442690521
3e4f2b1aeb076cff592279f94b1f495442690521 9d187b7f4819a69996dd27e3d66a5224e05d9f41 CI <CI@example.com> 1617683373 +1000 rebase -i (finish): refs/heads/branch2 onto fcf46511d7819220e0cc310ae6d891fadfdb79aa
9d187b7f4819a69996dd27e3d66a5224e05d9f41 9936b8f380c2937bb457ade468bfc7dc850293f9 CI <CI@example.com> 1617683374 +1000 rebase -i (finish): refs/heads/branch2 onto 68ac4e416c01408d37c59465852aa1856a4abdb1
9936b8f380c2937bb457ade468bfc7dc850293f9 9d187b7f4819a69996dd27e3d66a5224e05d9f41 CI <CI@example.com> 1617683376 +1000 [lazygit undo]: updating HEAD
9d187b7f4819a69996dd27e3d66a5224e05d9f41 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683377 +1000 [lazygit undo]: updating HEAD
3e4f2b1aeb076cff592279f94b1f495442690521 7ce8eac65e3ae50cb50a570dc775b745464f3a3e CI <CI@example.com> 1617683377 +1000 [lazygit undo]: updating HEAD
7ce8eac65e3ae50cb50a570dc775b745464f3a3e 3e4f2b1aeb076cff592279f94b1f495442690521 CI <CI@example.com> 1617683379 +1000 [lazygit redo]: updating HEAD

View File

@ -1,4 +0,0 @@
0000000000000000000000000000000000000000 6d95d7a7842625152ba887482879dfdaf247f591 CI <CI@example.com> 1617683370 +1000 commit (initial): file0
6d95d7a7842625152ba887482879dfdaf247f591 4f77a25a15ccca0273baa522f7281727f31ceeb8 CI <CI@example.com> 1617683370 +1000 commit: file1
4f77a25a15ccca0273baa522f7281727f31ceeb8 68ac4e416c01408d37c59465852aa1856a4abdb1 CI <CI@example.com> 1617683370 +1000 commit: file2
68ac4e416c01408d37c59465852aa1856a4abdb1 fcf46511d7819220e0cc310ae6d891fadfdb79aa CI <CI@example.com> 1617683370 +1000 commit: file4

View File

@ -1,2 +0,0 @@
x�ÎA
à @Ñ®=…ûBqF�Q(¥�UŽ1•’& =~s„n?oñu[×¹[ÈxéG­¶8&լ겨OmR–[ñ½£�0»õÝ-• §€„"N’‡„‰siEn1ƒ‘Om‡F{Ægýʺ/õ¦Ûú°@À”¼gg¯àœ3g=§zý“›6/Ì] 9

View File

@ -1,2 +0,0 @@
x+)JMU03c040031QHヒフI5`ーアコイ燹ヨカwチ�w.ス��モ[H
矢y�5�来ミ(桍ァ ^-ンW(x9

View File

@ -1,3 +0,0 @@
x�ÎA
à @Ñ®=…ûBqtÔJ)d•cŒ“ Ä& =~s„n?oñekm銿ôCÕÆÂN¥�aÎ~’kæJ•pŽ>×ij'gv>ôÝm"T„$ÐѲĂ)RôÌ@11r�*þô×vØa´÷a|ê—Û¾êM¶ö°� '
!;{çœ9ë9ÕõOnæeU4?O¿9-

View File

@ -1 +0,0 @@
3e4f2b1aeb076cff592279f94b1f495442690521

View File

@ -1 +0,0 @@
fcf46511d7819220e0cc310ae6d891fadfdb79aa

View File

@ -1 +0,0 @@
test0

View File

@ -1 +0,0 @@
test1

View File

@ -1 +0,0 @@
test2

View File

@ -1,3 +0,0 @@
line one
line two
line three

View File

@ -1 +0,0 @@
{"KeyEvents":[{"Timestamp":627,"Mod":0,"Key":259,"Ch":0},{"Timestamp":979,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1443,"Mod":0,"Key":256,"Ch":100},{"Timestamp":1723,"Mod":0,"Key":13,"Ch":13},{"Timestamp":2411,"Mod":0,"Key":256,"Ch":102},{"Timestamp":2811,"Mod":0,"Key":13,"Ch":13},{"Timestamp":3515,"Mod":0,"Key":256,"Ch":115},{"Timestamp":3994,"Mod":0,"Key":13,"Ch":13},{"Timestamp":5490,"Mod":0,"Key":256,"Ch":122},{"Timestamp":6490,"Mod":0,"Key":256,"Ch":122},{"Timestamp":7387,"Mod":0,"Key":256,"Ch":122},{"Timestamp":8428,"Mod":2,"Key":26,"Ch":26},{"Timestamp":9234,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"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"
echo test0 > file0
git add .
git commit -am file0
echo test1 > file1
git add .
git commit -am file1
echo test2 > file2
git add .
git commit -am file2
echo "line one" > file4
git add .
git commit -am file4
git checkout -b branch2
echo "line two" >> file4
git add .
git commit -am file4
echo "line three" >> file4
git add .
git commit -am file4
echo "line two" >> file2
git add .
git commit -am file2

View File

@ -1 +0,0 @@
{ "description": "undoing some changes to commits. Skipped because it's failing on CI for some reason", "speed": 10, "skip": true }