mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
migrate submodule add test
This commit is contained in:
parent
823d95a8c6
commit
010f6d7f6e
@ -32,7 +32,10 @@ func (self *PromptDriver) Type(value string) *PromptDriver {
|
||||
}
|
||||
|
||||
func (self *PromptDriver) Clear() *PromptDriver {
|
||||
panic("Clear method not yet implemented!")
|
||||
// TODO: soft-code this
|
||||
self.t.press("<c-u>")
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *PromptDriver) Confirm() {
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type ViewDriver struct {
|
||||
@ -104,32 +105,56 @@ func (self *ViewDriver) SelectedLineIdx(expected int) *ViewDriver {
|
||||
return self
|
||||
}
|
||||
|
||||
// focus the view (assumes the view is a side-view that can be focused via a keybinding)
|
||||
// focus the view (assumes the view is a side-view)
|
||||
func (self *ViewDriver) Focus() *ViewDriver {
|
||||
// we can easily change focus by switching to the view's window, but this assumes that the desired view
|
||||
// is at the top of that window. So for now we'll switch to the window then assert that the desired
|
||||
// view is on top (i.e. that it's the current view).
|
||||
// If we want to support other views e.g. the tags view, we'll need to add more logic here.
|
||||
viewName := self.getView().Name()
|
||||
|
||||
// using a map rather than a slice because we might add other views which share a window index later
|
||||
windowIndexMap := map[string]int{
|
||||
"status": 0,
|
||||
"files": 1,
|
||||
"localBranches": 2,
|
||||
"commits": 3,
|
||||
"stash": 4,
|
||||
type window struct {
|
||||
name string
|
||||
viewNames []string
|
||||
}
|
||||
windows := []window{
|
||||
{name: "status", viewNames: []string{"status"}},
|
||||
{name: "files", viewNames: []string{"files", "submodules"}},
|
||||
{name: "branches", viewNames: []string{"localBranches", "remotes", "tags"}},
|
||||
{name: "commits", viewNames: []string{"commits", "reflogCommits"}},
|
||||
{name: "stash", viewNames: []string{"stash"}},
|
||||
}
|
||||
|
||||
index, ok := windowIndexMap[viewName]
|
||||
if !ok {
|
||||
self.t.fail(fmt.Sprintf("Cannot focus view %s: Focus() method not implemented", viewName))
|
||||
for windowIndex, window := range windows {
|
||||
if lo.Contains(window.viewNames, viewName) {
|
||||
tabIndex := lo.IndexOf(window.viewNames, viewName)
|
||||
// jump to the desired window
|
||||
self.t.press(self.t.keys.Universal.JumpToBlock[windowIndex])
|
||||
|
||||
// assert we're in the window before continuing
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
currentWindowName := self.t.gui.CurrentContext().GetWindowName()
|
||||
// by convention the window is named after the first view in the window
|
||||
return currentWindowName == window.name, fmt.Sprintf("Expected to be in window '%s', but was in '%s'", window.name, currentWindowName)
|
||||
})
|
||||
|
||||
// switch to the desired tab
|
||||
currentViewName := self.t.gui.CurrentContext().GetViewName()
|
||||
currentViewTabIndex := lo.IndexOf(window.viewNames, currentViewName)
|
||||
if tabIndex > currentViewTabIndex {
|
||||
for i := 0; i < tabIndex-currentViewTabIndex; i++ {
|
||||
self.t.press(self.t.keys.Universal.NextTab)
|
||||
}
|
||||
} else if tabIndex < currentViewTabIndex {
|
||||
for i := 0; i < currentViewTabIndex-tabIndex; i++ {
|
||||
self.t.press(self.t.keys.Universal.PrevTab)
|
||||
}
|
||||
}
|
||||
|
||||
// assert that we're now in the expected view
|
||||
self.IsFocused()
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
self.t.press(self.t.keys.Universal.JumpToBlock[index])
|
||||
|
||||
// assert that we land in the expected view
|
||||
self.IsFocused()
|
||||
self.t.fail(fmt.Sprintf("Cannot focus view %s: Focus() method not implemented", viewName))
|
||||
|
||||
return self
|
||||
}
|
||||
|
65
pkg/integration/tests/submodule/add.go
Normal file
65
pkg/integration/tests/submodule/add.go
Normal file
@ -0,0 +1,65 @@
|
||||
package submodule
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var Add = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Add a submodule",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("first commit")
|
||||
shell.RunCommand("git clone --bare . ../other_repo")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Submodules().Focus().
|
||||
Press(keys.Universal.New).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Prompt().
|
||||
Title(Equals("new submodule URL:")).
|
||||
Type("../other_repo").Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().
|
||||
Title(Equals("new submodule name:")).
|
||||
InitialText(Equals("other_repo")).
|
||||
Clear().Type("my_submodule").Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().
|
||||
Title(Equals("new submodule path:")).
|
||||
InitialText(Equals("my_submodule")).
|
||||
Clear().Type("my_submodule_path").Confirm()
|
||||
}).
|
||||
Lines(
|
||||
Contains("my_submodule").IsSelected(),
|
||||
)
|
||||
|
||||
t.Views().Main().TopLines(
|
||||
Contains("Name: my_submodule"),
|
||||
Contains("Path: my_submodule_path"),
|
||||
Contains("Url: ../other_repo"),
|
||||
)
|
||||
|
||||
t.Views().Files().Focus().
|
||||
Lines(
|
||||
Contains(".gitmodules").IsSelected(),
|
||||
Contains("my_submodule_path (submodule)"),
|
||||
).
|
||||
Tap(func() {
|
||||
t.Views().Main().Content(
|
||||
Contains("[submodule \"my_submodule\"]").
|
||||
Contains("path = my_submodule_path").
|
||||
Contains("url = ../other_repo"),
|
||||
)
|
||||
}).
|
||||
SelectNextItem().
|
||||
Tap(func() {
|
||||
t.Views().Main().Content(
|
||||
Contains("Submodule my_submodule_path").
|
||||
Contains("(new submodule)"),
|
||||
)
|
||||
})
|
||||
},
|
||||
})
|
@ -23,6 +23,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/misc"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/patch_building"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/submodule"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/sync"
|
||||
)
|
||||
|
||||
@ -75,6 +76,7 @@ var tests = []*components.IntegrationTest{
|
||||
filter_by_path.SelectFile,
|
||||
filter_by_path.TypeFile,
|
||||
patch_building.BuildPatchAndCopyToClipboard,
|
||||
submodule.Add,
|
||||
}
|
||||
|
||||
func GetTests() []*components.IntegrationTest {
|
||||
|
@ -1 +0,0 @@
|
||||
ref: refs/heads/master
|
@ -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/submoduleAdd/actual/./repo
|
@ -1 +0,0 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
@ -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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
x�ÍM
|
||||
ƒ0@á®sŠÙJ&Nþ Á•Ç“ I¡Þ¾¡ÛÇ/µZ×HîÖÐâRÑì%d"Áàr@ÃX<-4dG…“5Š?ýݘfxNó(_®û&�ÔêÐä£ñ6Â]£Öêª×¤ËŸ\Õ³¬› ú5,ß
|
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
# pack-refs with: peeled fully-peeled sorted
|
||||
42530e986dbb65877ed8d61ca0c816e425e5c62e refs/heads/master
|
@ -1 +0,0 @@
|
||||
test
|
@ -1 +0,0 @@
|
||||
ref: refs/heads/master
|
@ -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 "blah"]
|
||||
url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleAdd/actual/other_repo
|
||||
active = true
|
@ -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,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 dc5bde4a09968b0819f34d193f6780df295d71cf CI <CI@example.com> 1648348101 +1100 commit: test
|
@ -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 dc5bde4a09968b0819f34d193f6780df295d71cf CI <CI@example.com> 1648348101 +1100 commit: test
|
@ -1 +0,0 @@
|
||||
ref: refs/heads/master
|
@ -1,14 +0,0 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
||||
worktree = ../../../haha
|
||||
[remote "origin"]
|
||||
url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleAdd/actual/other_repo
|
||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||
[branch "master"]
|
||||
remote = origin
|
||||
merge = refs/heads/master
|
@ -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 +0,0 @@
|
||||
0000000000000000000000000000000000000000 42530e986dbb65877ed8d61ca0c816e425e5c62e Jesse Duffield <jessedduffield@gmail.com> 1648348097 +1100 clone: from /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleAdd/actual/other_repo
|
@ -1 +0,0 @@
|
||||
0000000000000000000000000000000000000000 42530e986dbb65877ed8d61ca0c816e425e5c62e Jesse Duffield <jessedduffield@gmail.com> 1648348097 +1100 clone: from /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleAdd/actual/other_repo
|
@ -1 +0,0 @@
|
||||
0000000000000000000000000000000000000000 42530e986dbb65877ed8d61ca0c816e425e5c62e Jesse Duffield <jessedduffield@gmail.com> 1648348097 +1100 clone: from /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/submoduleAdd/actual/other_repo
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
x�ÍM
|
||||
ƒ0@á®sŠÙJ&Nþ Á•Ç“ I¡Þ¾¡ÛÇ/µZ×HîÖÐâRÑì%d"Áàr@ÃX<-4dG…“5Š?ýݘfxNó(_®û&�ÔêÐä£ñ6Â]£Öêª×¤ËŸ\Õ³¬› ú5,ß
|
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
# pack-refs with: peeled fully-peeled sorted
|
||||
42530e986dbb65877ed8d61ca0c816e425e5c62e refs/remotes/origin/master
|
@ -1 +0,0 @@
|
||||
42530e986dbb65877ed8d61ca0c816e425e5c62e
|
@ -1 +0,0 @@
|
||||
ref: refs/remotes/origin/master
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
x�ÍM
|
||||
ƒ0@á®sŠÙJ&Nþ Á•Ç“ I¡Þ¾¡ÛÇ/µZ×HîÖÐâRÑì%d"Áàr@ÃX<-4dG…“5Š?ýݘfxNó(_®û&�ÔêÐä£ñ6Â]£Öêª×¤ËŸ\Õ³¬› ú5,ß
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
dc5bde4a09968b0819f34d193f6780df295d71cf
|
@ -1,3 +0,0 @@
|
||||
[submodule "blah"]
|
||||
path = haha
|
||||
url = ../other_repo
|
@ -1 +0,0 @@
|
||||
gitdir: ../.git/modules/blah
|
@ -1 +0,0 @@
|
||||
test1
|
@ -1 +0,0 @@
|
||||
test2
|
@ -1 +0,0 @@
|
||||
test1
|
@ -1 +0,0 @@
|
||||
test2
|
@ -1 +0,0 @@
|
||||
{"KeyEvents":[{"Timestamp":1858,"Mod":0,"Key":256,"Ch":93},{"Timestamp":4332,"Mod":0,"Key":256,"Ch":110},{"Timestamp":5067,"Mod":0,"Key":256,"Ch":46},{"Timestamp":5188,"Mod":0,"Key":256,"Ch":46},{"Timestamp":5323,"Mod":0,"Key":256,"Ch":47},{"Timestamp":5532,"Mod":0,"Key":256,"Ch":111},{"Timestamp":5652,"Mod":0,"Key":256,"Ch":116},{"Timestamp":5743,"Mod":0,"Key":256,"Ch":104},{"Timestamp":5862,"Mod":0,"Key":256,"Ch":101},{"Timestamp":5892,"Mod":0,"Key":256,"Ch":114},{"Timestamp":6102,"Mod":0,"Key":256,"Ch":95},{"Timestamp":6297,"Mod":0,"Key":256,"Ch":114},{"Timestamp":6312,"Mod":0,"Key":256,"Ch":101},{"Timestamp":6402,"Mod":0,"Key":256,"Ch":112},{"Timestamp":6432,"Mod":0,"Key":256,"Ch":111},{"Timestamp":6718,"Mod":0,"Key":13,"Ch":13},{"Timestamp":7632,"Mod":0,"Key":127,"Ch":127},{"Timestamp":7966,"Mod":0,"Key":127,"Ch":127},{"Timestamp":7982,"Mod":0,"Key":127,"Ch":127},{"Timestamp":7998,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8015,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8031,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8049,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8065,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8081,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8097,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8113,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8129,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8146,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8162,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8178,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8195,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8212,"Mod":0,"Key":127,"Ch":127},{"Timestamp":8397,"Mod":0,"Key":256,"Ch":98},{"Timestamp":8578,"Mod":0,"Key":256,"Ch":108},{"Timestamp":8698,"Mod":0,"Key":256,"Ch":97},{"Timestamp":8787,"Mod":0,"Key":256,"Ch":104},{"Timestamp":9012,"Mod":0,"Key":13,"Ch":13},{"Timestamp":9493,"Mod":0,"Key":127,"Ch":127},{"Timestamp":9717,"Mod":0,"Key":127,"Ch":127},{"Timestamp":9868,"Mod":0,"Key":127,"Ch":127},{"Timestamp":9973,"Mod":0,"Key":127,"Ch":127},{"Timestamp":10168,"Mod":0,"Key":256,"Ch":104},{"Timestamp":10228,"Mod":0,"Key":256,"Ch":97},{"Timestamp":10257,"Mod":0,"Key":256,"Ch":104},{"Timestamp":10393,"Mod":0,"Key":256,"Ch":97},{"Timestamp":10752,"Mod":0,"Key":13,"Ch":13},{"Timestamp":12612,"Mod":0,"Key":256,"Ch":91},{"Timestamp":13543,"Mod":0,"Key":256,"Ch":99},{"Timestamp":13797,"Mod":0,"Key":256,"Ch":116},{"Timestamp":13857,"Mod":0,"Key":256,"Ch":101},{"Timestamp":14037,"Mod":0,"Key":256,"Ch":115},{"Timestamp":14081,"Mod":0,"Key":256,"Ch":116},{"Timestamp":14368,"Mod":0,"Key":13,"Ch":13},{"Timestamp":15312,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":36}]}
|
@ -1,29 +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"
|
||||
# see https://vielmetti.typepad.com/logbook/2022/10/git-security-fixes-lead-to-fatal-transport-file-not-allowed-error-in-ci-systems-cve-2022-39253.html
|
||||
# NOTE: I don't think this actually works if it's only applied to the repo.
|
||||
# On CI we set the global setting, but given it's a security concern I don't want
|
||||
# people to do that for their locals.
|
||||
git config protocol.file.allow always
|
||||
|
||||
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
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"description": "Add submodule",
|
||||
"speed": 5
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user