migrate submodule reset test

This commit is contained in:
Jesse Duffield
2023-02-12 18:00:45 +11:00
parent d7956c481d
commit 3cfdae4116
69 changed files with 119 additions and 143 deletions

View File

@@ -26,6 +26,15 @@ var Enter = NewIntegrationTest(NewIntegrationTestArgs{
shell.Commit("add submodule")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
assertInParentRepo := func() {
t.Views().Status().Content(Contains("repo"))
}
assertInSubmodule := func() {
t.Views().Status().Content(Contains("my_submodule"))
}
assertInParentRepo()
t.Views().Submodules().Focus().
Lines(
Contains("my_submodule").IsSelected(),
@@ -33,6 +42,8 @@ var Enter = NewIntegrationTest(NewIntegrationTestArgs{
// enter the submodule
PressEnter()
assertInSubmodule()
t.Views().Files().IsFocused().
Press("e").
Tap(func() {
@@ -41,6 +52,8 @@ var Enter = NewIntegrationTest(NewIntegrationTestArgs{
// return to the parent repo
PressEscape()
assertInParentRepo()
t.Views().Submodules().IsFocused()
// we see the new commit in the submodule is ready to be staged in the parent repo

View File

@@ -0,0 +1,105 @@
package submodule
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Reset = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Enter a submodule, create a commit and stage some changes, then reset the submodule from back in the parent repo. This test captures functionality around getting a dirty submodule out of your files panel.",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
cfg.UserConfig.CustomCommands = []config.CustomCommand{
{
Key: "e",
Context: "files",
Command: "git commit --allow-empty -m \"empty commit\" && echo \"my_file content\" > my_file",
},
}
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
shell.RunCommand("git clone --bare . ../other_repo")
shell.RunCommand("git submodule add ../other_repo my_submodule")
shell.GitAddAll()
shell.Commit("add submodule")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
assertInParentRepo := func() {
t.Views().Status().Content(Contains("repo"))
}
assertInSubmodule := func() {
t.Views().Status().Content(Contains("my_submodule"))
}
assertInParentRepo()
t.Views().Submodules().Focus().
Lines(
Contains("my_submodule").IsSelected(),
).
// enter the submodule
PressEnter()
assertInSubmodule()
t.Views().Status().Content(Contains("my_submodule"))
t.Views().Files().IsFocused().
Press("e").
Tap(func() {
t.Views().Commits().Content(Contains("empty commit"))
t.Views().Files().Content(Contains("my_file"))
}).
Lines(
Contains("my_file").IsSelected(),
).
// stage my_file
PressPrimaryAction().
// return to the parent repo
PressEscape()
assertInParentRepo()
t.Views().Submodules().IsFocused()
t.Views().Main().Content(Contains("Submodule my_submodule contains modified content"))
t.Views().Files().Focus().
Lines(
MatchesRegexp(` M.*my_submodule \(submodule\)`).IsSelected(),
).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("my_submodule")).Select(Contains("stash uncommitted submodule changes and update")).Confirm()
}).
IsEmpty()
t.Views().Submodules().Focus().
PressEnter()
assertInSubmodule()
// submodule has been hard reset to the commit the parent repo specifies
t.Views().Branches().Lines(
Contains("HEAD detached").IsSelected(),
Contains("master"),
)
// empty commit is gone
t.Views().Commits().Lines(
Contains("first commit").IsSelected(),
)
// the staged change has been stashed
t.Views().Files().IsEmpty()
t.Views().Stash().Focus().
Lines(
Contains("WIP on master").IsSelected(),
)
t.Views().Main().Content(Contains("my_file content"))
},
})

View File

@@ -79,6 +79,7 @@ var tests = []*components.IntegrationTest{
submodule.Add,
submodule.Remove,
submodule.Enter,
submodule.Reset,
}
func GetTests() []*components.IntegrationTest {

View File

@@ -1,6 +0,0 @@
disableStartupPopups: true
customCommands:
- key: 'N'
description: 'Add file'
context: 'files'
command: 'echo "haha" > output.txt'

View File

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

View File

@@ -1,8 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleReset/actual/./repo

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,2 +0,0 @@
x<01><>M
<EFBFBD>0@<40><>s<EFBFBD><73>J&N<><4E><14><><EFBFBD><18>  I<>޾<1E><><EFBFBD>/<2F>Z<EFBFBD>H<><48><11><>R<EFBFBD><52>%d"<22><>r@<40>X<-4dG<64><47>5<EFBFBD>?<3F><><0E>fxN<78>(_<><5F>&<26><><EFBFBD> <0B><0E><><EFBFBD>6<EFBFBD>]<5D><><EFBFBD><EFBFBD>פ˟\ճ<><D5B3><EFBFBD><EFBFBD>5,<2C>

View File

@@ -1,2 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
42530e986dbb65877ed8d61ca0c816e425e5c62e refs/heads/master

View File

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

View File

@@ -1,13 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[user]
email = CI@example.com
name = CI
[submodule "other_repo"]
url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleReset/actual/other_repo
active = true

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,3 +0,0 @@
0000000000000000000000000000000000000000 a50a5125768001a3ea263ffb7cafbc421a508153 CI <CI@example.com> 1534792759 +0100 commit (initial): myfile1
a50a5125768001a3ea263ffb7cafbc421a508153 42530e986dbb65877ed8d61ca0c816e425e5c62e CI <CI@example.com> 1534792759 +0100 commit: myfile2
42530e986dbb65877ed8d61ca0c816e425e5c62e 9d10a5a0a21eb2cfdb6206f474ed57fd5cd51440 CI <CI@example.com> 1534792759 +0100 commit: add submodule

View File

@@ -1,3 +0,0 @@
0000000000000000000000000000000000000000 a50a5125768001a3ea263ffb7cafbc421a508153 CI <CI@example.com> 1534792759 +0100 commit (initial): myfile1
a50a5125768001a3ea263ffb7cafbc421a508153 42530e986dbb65877ed8d61ca0c816e425e5c62e CI <CI@example.com> 1534792759 +0100 commit: myfile2
42530e986dbb65877ed8d61ca0c816e425e5c62e 9d10a5a0a21eb2cfdb6206f474ed57fd5cd51440 CI <CI@example.com> 1534792759 +0100 commit: add submodule

View File

@@ -1 +0,0 @@
42530e986dbb65877ed8d61ca0c816e425e5c62e

View File

@@ -1 +0,0 @@
a50a5125768001a3ea263ffb7cafbc421a508153

View File

@@ -1,14 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
worktree = ../../../other_repo
[remote "origin"]
url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleReset/actual/other_repo
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

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,5 +0,0 @@
0000000000000000000000000000000000000000 42530e986dbb65877ed8d61ca0c816e425e5c62e Jesse Duffield <jessedduffield@gmail.com> 1534792759 +0100 clone: from /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleReset/actual/other_repo
42530e986dbb65877ed8d61ca0c816e425e5c62e a50a5125768001a3ea263ffb7cafbc421a508153 Jesse Duffield <jessedduffield@gmail.com> 1648348154 +1100 rebase -i (start): checkout a50a5125768001a3ea263ffb7cafbc421a508153
a50a5125768001a3ea263ffb7cafbc421a508153 a50a5125768001a3ea263ffb7cafbc421a508153 Jesse Duffield <jessedduffield@gmail.com> 1648348154 +1100 rebase -i (finish): returning to refs/heads/master
a50a5125768001a3ea263ffb7cafbc421a508153 a50a5125768001a3ea263ffb7cafbc421a508153 Jesse Duffield <jessedduffield@gmail.com> 1648348162 +1100 reset: moving to HEAD
a50a5125768001a3ea263ffb7cafbc421a508153 42530e986dbb65877ed8d61ca0c816e425e5c62e Jesse Duffield <jessedduffield@gmail.com> 1648348162 +1100 checkout: moving from master to 42530e986dbb65877ed8d61ca0c816e425e5c62e

View File

@@ -1,2 +0,0 @@
0000000000000000000000000000000000000000 42530e986dbb65877ed8d61ca0c816e425e5c62e Jesse Duffield <jessedduffield@gmail.com> 1534792759 +0100 clone: from /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleReset/actual/other_repo
42530e986dbb65877ed8d61ca0c816e425e5c62e a50a5125768001a3ea263ffb7cafbc421a508153 Jesse Duffield <jessedduffield@gmail.com> 1648348154 +1100 rebase -i (finish): refs/heads/master onto a50a5125768001a3ea263ffb7cafbc421a508153

View File

@@ -1 +0,0 @@
0000000000000000000000000000000000000000 42530e986dbb65877ed8d61ca0c816e425e5c62e Jesse Duffield <jessedduffield@gmail.com> 1534792759 +0100 clone: from /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleReset/actual/other_repo

View File

@@ -1 +0,0 @@
0000000000000000000000000000000000000000 874e570cb4ea7387ba59054b315aa584038cacea Jesse Duffield <jessedduffield@gmail.com> 1648348162 +1100 WIP on master: a50a512 myfile1

View File

@@ -1,2 +0,0 @@
x<01><>A<0E> E]s<>ٛ<18><>Pc<50> W<>b<EFBFBD>A<EFBFBD>R<EFBFBD>B<17><>6<EFBFBD>.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;hmv}f<06>N<EFBFBD>,<2C><>-<2D><><EFBFBD><EFBFBD>l<EFBFBD>'<17><><EFBFBD>K<EFBFBD><07><><EFBFBD><EFBFBD><EFBFBD>3ܹ5<DCB9>ےR<DB92>1<EFBFBD><31><EFBFBD>q<EFBFBD>?<3F>>
<EFBFBD><EFBFBD>j<><6A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>հWJJ<4A><4A><EFBFBD><EFBFBD><EFBFBD>_<11>L}<7D><><EFBFBD>)<29>ܠNP<4E><50><EFBFBD><13><>d<EFBFBD><64><EFBFBD><EFBFBD>&%<25><><EFBFBD>J<EFBFBD>

View File

@@ -1,2 +0,0 @@
x<01><>1O<31>0 <0C><><EFBFBD>+<2B>#<23>8<EFBFBD>!<21><><1B>c;<3B><><EFBFBD><15>}<03><> <20>~<01><>}:['<27><>L<EFBFBD><4C><EFBFBD>o<EFBFBD><6F><EFBFBD>AQk<51>ޠ<EFBFBD><DEA0>c<EFBFBD><14>s<EFBFBD><73><EFBFBD>Qj<51>2<EFBFBD>D<EFBFBD><44>ov><1C>g<EFBFBD><67>%<25><><EFBFBD><EFBFBD>8<EFBFBD><38>Z-­J
<EFBFBD><02>W^C<>A#%_<><5F>TE<54><45>F <0C>}<04><>/`<60><>݅R<DD85>Gbi$<24><>+<19>H{P<>Ɓ/<2F>i<EFBFBD>ܫ<EFBFBD><DCAB><EFBFBD><EFBFBD>Kk<4B><6B><EFBFBD>><><7F><EFBFBD>~<7E>Xx<58><78>d]<1D>D1<11><>n<01><1F>ۧ8<DBA7>_%<25><>˛[<5B>n<EFBFBD><6E>7<EFBFBD>_<EFBFBD>q<EFBFBD>w<EFBFBD>f<EFBFBD><1F>Wn<57>

View File

@@ -1,2 +0,0 @@
x<01><>M
<EFBFBD>0@<40><>s<EFBFBD><73>J&N<><4E><14><><EFBFBD><18>  I<>޾<1E><><EFBFBD>/<2F>Z<EFBFBD>H<><48><11><>R<EFBFBD><52>%d"<22><>r@<40>X<-4dG<64><47>5<EFBFBD>?<3F><><0E>fxN<78>(_<><5F>&<26><><EFBFBD> <0B><0E><><EFBFBD>6<EFBFBD>]<5D><><EFBFBD><EFBFBD>פ˟\ճ<><D5B3><EFBFBD><EFBFBD>5,<2C>

View File

@@ -1,2 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
42530e986dbb65877ed8d61ca0c816e425e5c62e refs/remotes/origin/master

View File

@@ -1 +0,0 @@
a50a5125768001a3ea263ffb7cafbc421a508153

View File

@@ -1 +0,0 @@
874e570cb4ea7387ba59054b315aa584038cacea

View File

@@ -1,2 +0,0 @@
x<01><>M
<EFBFBD>0@<40><>s<EFBFBD><73>J&N<><4E><14><><EFBFBD><18>  I<>޾<1E><><EFBFBD>/<2F>Z<EFBFBD>H<><48><11><>R<EFBFBD><52>%d"<22><>r@<40>X<-4dG<64><47>5<EFBFBD>?<3F><><0E>fxN<78>(_<><5F>&<26><><EFBFBD> <0B><0E><><EFBFBD>6<EFBFBD>]<5D><><EFBFBD><EFBFBD>פ˟\ճ<><D5B3><EFBFBD><EFBFBD>5,<2C>

View File

@@ -1 +0,0 @@
9d10a5a0a21eb2cfdb6206f474ed57fd5cd51440

View File

@@ -1,3 +0,0 @@
[submodule "other_repo"]
path = other_repo
url = ../other_repo

View File

@@ -1 +0,0 @@
gitdir: ../.git/modules/other_repo

View File

@@ -1 +0,0 @@
{"KeyEvents":[{"Timestamp":653,"Mod":0,"Key":256,"Ch":93},{"Timestamp":1685,"Mod":0,"Key":13,"Ch":13},{"Timestamp":2749,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2893,"Mod":0,"Key":259,"Ch":0},{"Timestamp":3229,"Mod":0,"Key":256,"Ch":100},{"Timestamp":3661,"Mod":0,"Key":13,"Ch":13},{"Timestamp":4069,"Mod":0,"Key":260,"Ch":0},{"Timestamp":4189,"Mod":0,"Key":260,"Ch":0},{"Timestamp":5180,"Mod":0,"Key":256,"Ch":78},{"Timestamp":6508,"Mod":0,"Key":256,"Ch":32},{"Timestamp":7311,"Mod":0,"Key":27,"Ch":0},{"Timestamp":8212,"Mod":0,"Key":256,"Ch":91},{"Timestamp":10268,"Mod":0,"Key":256,"Ch":100},{"Timestamp":12165,"Mod":0,"Key":13,"Ch":13},{"Timestamp":13741,"Mod":0,"Key":256,"Ch":93},{"Timestamp":14317,"Mod":0,"Key":13,"Ch":13},{"Timestamp":16645,"Mod":0,"Key":259,"Ch":0},{"Timestamp":16805,"Mod":0,"Key":259,"Ch":0},{"Timestamp":17005,"Mod":0,"Key":259,"Ch":0},{"Timestamp":18588,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]}

View File

@@ -1,27 +0,0 @@
#!/bin/sh
set -e
cd $1
export GIT_COMMITTER_DATE="Mon 20 Aug 2018 20:19:19 BST"
export GIT_AUTHOR_DATE="Mon 20 Aug 2018 20:19:19 BST"
git init
git config user.email "CI@example.com"
git config user.name "CI"
echo test1 > myfile1
git add .
git commit -am "myfile1"
echo test2 > myfile2
git add .
git commit -am "myfile2"
cd ..
git clone --bare ./repo other_repo
cd repo
git -c protocol.file.allow=always submodule add ../other_repo
git commit -am "add submodule"

View File

@@ -1,4 +0,0 @@
{
"description": "After making some changes in a submodule, we reset the submodule from the parent repo",
"speed": 10
}