mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-19 21:28:28 +02:00
add commit revert integration test
This commit is contained in:
parent
b40190bd94
commit
bc4ace8357
@ -2,6 +2,7 @@ package components
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -259,3 +260,19 @@ func (self *Assert) assertWithRetries(test func() (bool, string)) {
|
|||||||
func (self *Assert) Fail(message string) {
|
func (self *Assert) Fail(message string) {
|
||||||
self.gui.Fail(message)
|
self.gui.Fail(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This does _not_ check the files panel, it actually checks the filesystem
|
||||||
|
func (self *Assert) FileSystemPathPresent(path string) {
|
||||||
|
self.assertWithRetries(func() (bool, string) {
|
||||||
|
_, err := os.Stat(path)
|
||||||
|
return err == nil, fmt.Sprintf("Expected path '%s' to exist, but it does not", path)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// This does _not_ check the files panel, it actually checks the filesystem
|
||||||
|
func (self *Assert) FileSystemPathNotPresent(path string) {
|
||||||
|
self.assertWithRetries(func() (bool, string) {
|
||||||
|
_, err := os.Stat(path)
|
||||||
|
return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
37
pkg/integration/tests/commit/revert.go
Normal file
37
pkg/integration/tests/commit/revert.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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: "",
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.CreateFile("myfile", "myfile content")
|
||||||
|
shell.GitAddAll()
|
||||||
|
shell.Commit("first commit")
|
||||||
|
},
|
||||||
|
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||||
|
assert.CommitCount(1)
|
||||||
|
|
||||||
|
input.SwitchToCommitsWindow()
|
||||||
|
|
||||||
|
input.PressKeys(keys.Commits.RevertCommit)
|
||||||
|
assert.InConfirm()
|
||||||
|
assert.MatchCurrentViewTitle(Equals("Revert commit"))
|
||||||
|
assert.MatchCurrentViewContent(MatchesRegexp("Are you sure you want to revert \\w+?"))
|
||||||
|
input.Confirm()
|
||||||
|
|
||||||
|
assert.CommitCount(2)
|
||||||
|
assert.MatchHeadCommitMessage(Contains("Revert \"first commit\""))
|
||||||
|
input.PreviousItem()
|
||||||
|
assert.MatchMainViewContent(Contains("-myfile content"))
|
||||||
|
assert.FileSystemPathNotPresent("myfile")
|
||||||
|
|
||||||
|
input.Wait(10)
|
||||||
|
},
|
||||||
|
})
|
@ -37,6 +37,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
cherry_pick.CherryPickConflicts,
|
cherry_pick.CherryPickConflicts,
|
||||||
commit.Commit,
|
commit.Commit,
|
||||||
commit.CommitMultiline,
|
commit.CommitMultiline,
|
||||||
|
commit.Revert,
|
||||||
commit.NewBranch,
|
commit.NewBranch,
|
||||||
commit.Staged,
|
commit.Staged,
|
||||||
commit.Unstaged,
|
commit.Unstaged,
|
||||||
|
@ -1 +0,0 @@
|
|||||||
revert commit
|
|
@ -1 +0,0 @@
|
|||||||
ref: refs/heads/master
|
|
@ -1,10 +0,0 @@
|
|||||||
[core]
|
|
||||||
repositoryformatversion = 0
|
|
||||||
filemode = true
|
|
||||||
bare = false
|
|
||||||
logallrefupdates = true
|
|
||||||
ignorecase = true
|
|
||||||
precomposeunicode = true
|
|
||||||
[user]
|
|
||||||
email = CI@example.com
|
|
||||||
name = CI
|
|
@ -1 +0,0 @@
|
|||||||
Unnamed repository; edit this file 'description' to name the repository.
|
|
Binary file not shown.
@ -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
|
|
@ -1,5 +0,0 @@
|
|||||||
0000000000000000000000000000000000000000 9eaae8f342ca71c060b760870a715a6303905935 CI <CI@example.com> 1643148217 +1100 commit (initial): file0
|
|
||||||
9eaae8f342ca71c060b760870a715a6303905935 1727eeb6864e52a8967a1a494099359dbdfcc235 CI <CI@example.com> 1643148217 +1100 commit: file1
|
|
||||||
1727eeb6864e52a8967a1a494099359dbdfcc235 b781ffd3aa940dde39f73c9149b67e2b128de085 CI <CI@example.com> 1643148217 +1100 commit: file2
|
|
||||||
b781ffd3aa940dde39f73c9149b67e2b128de085 ab15072795e72a2061bc40060494c3ca2138b297 CI <CI@example.com> 1643148219 +1100 revert: Revert "file1"
|
|
||||||
ab15072795e72a2061bc40060494c3ca2138b297 7e03c9a9538a907c936de5c9a2154707b9ee541c CI <CI@example.com> 1643148227 +1100 commit (amend): revert commit
|
|
@ -1,5 +0,0 @@
|
|||||||
0000000000000000000000000000000000000000 9eaae8f342ca71c060b760870a715a6303905935 CI <CI@example.com> 1643148217 +1100 commit (initial): file0
|
|
||||||
9eaae8f342ca71c060b760870a715a6303905935 1727eeb6864e52a8967a1a494099359dbdfcc235 CI <CI@example.com> 1643148217 +1100 commit: file1
|
|
||||||
1727eeb6864e52a8967a1a494099359dbdfcc235 b781ffd3aa940dde39f73c9149b67e2b128de085 CI <CI@example.com> 1643148217 +1100 commit: file2
|
|
||||||
b781ffd3aa940dde39f73c9149b67e2b128de085 ab15072795e72a2061bc40060494c3ca2138b297 CI <CI@example.com> 1643148219 +1100 revert: Revert "file1"
|
|
||||||
ab15072795e72a2061bc40060494c3ca2138b297 7e03c9a9538a907c936de5c9a2154707b9ee541c CI <CI@example.com> 1643148227 +1100 commit (amend): revert commit
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
|||||||
x+)JMU03c040031QHËÌI5`°±º²àŸÖ¶wÁ‡Þw.½ùhïTÓ[H
|
|
||||||
Œ$x~5(í;÷rÕ¢ðªþ–WÚó-Ôö9
|
|
@ -1,4 +0,0 @@
|
|||||||
x}ŽK
|
|
||||||
1]ç½$�O'�A„YÍ1òé `œ!DñøèÚmQõxymí6@Iy�tDfëÙ:MÒ„Xl
|
|
||||||
ŠÈ¡-šŒ"4)c[ìü�œÇZ‹Ž1Y
|
|
||||||
ëP�ÎMHäX%T¾°ôVÄ縮æ¦y¹ð;¶íΧ¼¶3 ½ï*pD”Rìt?5ø¿®ÜO�_Ü|3ñÂ<
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
|||||||
x��K
|
|
||||||
Т0@]чй��ќ& "tеcL� [J�o�ріёМВѕО
/убI�8�ZЈж�мrЋо@в" ЁЭ�кљ�їF�"9Ppт�)�ШР.9��ѕЉцкJAыЦk;є4ыћ4?хЫ}_хVЖўа�GQ_�Q'=Ї�ќЉЋЖЌ�ъЁ\9Ј
|
|
@ -1,2 +0,0 @@
|
|||||||
x+)JMU03c040031QHヒフI5`ーアコイ燹ヨカwチ�w.ス��モ[H
|
|
||||||
矢y�5�来ミ(桍ァ^-ンW(x9
|
|
@ -1 +0,0 @@
|
|||||||
7e03c9a9538a907c936de5c9a2154707b9ee541c
|
|
@ -1 +0,0 @@
|
|||||||
test0
|
|
@ -1 +0,0 @@
|
|||||||
test2
|
|
@ -1 +0,0 @@
|
|||||||
{"KeyEvents":[{"Timestamp":614,"Mod":0,"Key":259,"Ch":0},{"Timestamp":749,"Mod":0,"Key":259,"Ch":0},{"Timestamp":980,"Mod":0,"Key":258,"Ch":0},{"Timestamp":1219,"Mod":0,"Key":256,"Ch":116},{"Timestamp":1854,"Mod":0,"Key":13,"Ch":13},{"Timestamp":2469,"Mod":0,"Key":257,"Ch":0},{"Timestamp":2725,"Mod":0,"Key":257,"Ch":0},{"Timestamp":3892,"Mod":0,"Key":256,"Ch":114},{"Timestamp":5421,"Mod":2,"Key":21,"Ch":21},{"Timestamp":5854,"Mod":2,"Key":21,"Ch":21},{"Timestamp":6197,"Mod":2,"Key":21,"Ch":21},{"Timestamp":6469,"Mod":2,"Key":21,"Ch":21},{"Timestamp":6781,"Mod":2,"Key":21,"Ch":21},{"Timestamp":7078,"Mod":2,"Key":21,"Ch":21},{"Timestamp":7907,"Mod":0,"Key":256,"Ch":114},{"Timestamp":7989,"Mod":0,"Key":256,"Ch":101},{"Timestamp":8148,"Mod":0,"Key":256,"Ch":118},{"Timestamp":8285,"Mod":0,"Key":256,"Ch":101},{"Timestamp":8356,"Mod":0,"Key":256,"Ch":114},{"Timestamp":8493,"Mod":0,"Key":256,"Ch":116},{"Timestamp":8604,"Mod":0,"Key":256,"Ch":32},{"Timestamp":8700,"Mod":0,"Key":256,"Ch":102},{"Timestamp":9125,"Mod":0,"Key":127,"Ch":127},{"Timestamp":9189,"Mod":0,"Key":256,"Ch":99},{"Timestamp":9317,"Mod":0,"Key":256,"Ch":111},{"Timestamp":9509,"Mod":0,"Key":256,"Ch":109},{"Timestamp":9637,"Mod":0,"Key":256,"Ch":109},{"Timestamp":9685,"Mod":0,"Key":256,"Ch":105},{"Timestamp":9781,"Mod":0,"Key":256,"Ch":116},{"Timestamp":9918,"Mod":0,"Key":13,"Ch":13},{"Timestamp":11110,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]}
|
|
@ -1,22 +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
|
|
@ -1 +0,0 @@
|
|||||||
{ "description": "Reverting a commit. Note here that our snapshot test fails if the commit SHA is included in the message hence the renaming of the revert commit after creating it", "speed": 20 }
|
|
Loading…
x
Reference in New Issue
Block a user