mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
migrate fetchPrune integration test
This commit is contained in:
parent
8a1c763942
commit
277ca706eb
34 changed files with 74 additions and 117 deletions
|
@ -170,3 +170,26 @@ func (self *Shell) SetConfig(key string, value string) *Shell {
|
||||||
self.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value))
|
self.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value))
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// creates a clone of the repo in a sibling directory and adds the clone
|
||||||
|
// as a remote, then fetches it.
|
||||||
|
func (self *Shell) CloneIntoRemote(name string) *Shell {
|
||||||
|
self.RunCommand(fmt.Sprintf("git clone --bare . ../%s", name))
|
||||||
|
self.RunCommand(fmt.Sprintf("git remote add %s ../%s", name, name))
|
||||||
|
self.RunCommand(fmt.Sprintf("git fetch %s", name))
|
||||||
|
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
// e.g. branch: 'master', upstream: 'origin/master'
|
||||||
|
func (self *Shell) SetBranchUpstream(branch string, upstream string) *Shell {
|
||||||
|
self.RunCommand(fmt.Sprintf("git branch --set-upstream-to=%s %s", upstream, branch))
|
||||||
|
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Shell) RemoveRemoteBranch(remoteName string, branch string) *Shell {
|
||||||
|
self.RunCommand(fmt.Sprintf("git -C ../%s branch -d %s", remoteName, branch))
|
||||||
|
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
49
pkg/integration/tests/sync/fetch_prune.go
Normal file
49
pkg/integration/tests/sync/fetch_prune.go
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package sync
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var FetchPrune = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Fetch from the remote with the 'prune' option set in the git config",
|
||||||
|
ExtraCmdArgs: "",
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
config.UserConfig.Git.AutoFetch = false
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
// This option makes it so that git checks for deleted branches in the remote
|
||||||
|
// upon fetching.
|
||||||
|
shell.SetConfig("fetch.prune", "true")
|
||||||
|
|
||||||
|
shell.EmptyCommit("my commit message")
|
||||||
|
|
||||||
|
shell.NewBranch("branch_to_remove")
|
||||||
|
shell.Checkout("master")
|
||||||
|
shell.CloneIntoRemote("origin")
|
||||||
|
shell.SetBranchUpstream("master", "origin/master")
|
||||||
|
shell.SetBranchUpstream("branch_to_remove", "origin/branch_to_remove")
|
||||||
|
|
||||||
|
// # unbenownst to our test repo we're removing the branch on the remote, so upon
|
||||||
|
// # fetching with prune: true we expect git to realise the remote branch is gone
|
||||||
|
shell.RemoveRemoteBranch("origin", "branch_to_remove")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Branches().
|
||||||
|
Lines(
|
||||||
|
Contains("master"),
|
||||||
|
Contains("branch_to_remove").DoesNotContain("upstream gone"),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.Views().Files().
|
||||||
|
IsFocused().
|
||||||
|
Press(keys.Files.Fetch)
|
||||||
|
|
||||||
|
t.Views().Branches().
|
||||||
|
Lines(
|
||||||
|
Contains("master"),
|
||||||
|
Contains("branch_to_remove").Contains("upstream gone"),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/misc"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/misc"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Here is where we lists the actual tests that will run. When you create a new test,
|
// Here is where we lists the actual tests that will run. When you create a new test,
|
||||||
|
@ -64,6 +65,7 @@ var tests = []*components.IntegrationTest{
|
||||||
diff.Diff,
|
diff.Diff,
|
||||||
diff.DiffAndApplyPatch,
|
diff.DiffAndApplyPatch,
|
||||||
diff.DiffCommits,
|
diff.DiffCommits,
|
||||||
|
sync.FetchPrune,
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTests() []*components.IntegrationTest {
|
func GetTests() []*components.IntegrationTest {
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
disableStartupPopups: true
|
|
||||||
git:
|
|
||||||
autoFetch: false
|
|
||||||
gui:
|
|
||||||
theme:
|
|
||||||
activeBorderColor:
|
|
||||||
- green
|
|
||||||
- bold
|
|
||||||
SelectedRangeBgcolor:
|
|
||||||
- reverse
|
|
|
@ -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/fetchPrune/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.
|
@ -1,3 +0,0 @@
|
||||||
x<01>ÍA
|
|
||||||
Â0@Q×9ÅìɤÓI¡«cšL°Ð!R"èííÜ~üÜÌÖH|ê»*xå\½ð¯š
|
|
||||||
‘bâ’0ÖH
…©Jƒ“w¶¦nÓüÐ<C3BC>ØkÓKnvdJÃ"#œ½wG=&]ÿäξuÝÝ2Ž,Ï
|
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
||||||
# pack-refs with: peeled fully-peeled sorted
|
|
||||||
75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 refs/heads/master
|
|
|
@ -1 +0,0 @@
|
||||||
myfile1
|
|
|
@ -1 +0,0 @@
|
||||||
75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 branch 'master' of ../origin
|
|
|
@ -1 +0,0 @@
|
||||||
ref: refs/heads/master
|
|
|
@ -1,21 +0,0 @@
|
||||||
[core]
|
|
||||||
repositoryformatversion = 0
|
|
||||||
filemode = true
|
|
||||||
bare = false
|
|
||||||
logallrefupdates = true
|
|
||||||
ignorecase = true
|
|
||||||
precomposeunicode = true
|
|
||||||
[user]
|
|
||||||
email = CI@example.com
|
|
||||||
name = CI
|
|
||||||
[fetch]
|
|
||||||
prune = true
|
|
||||||
[remote "origin"]
|
|
||||||
url = ../origin
|
|
||||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
||||||
[branch "master"]
|
|
||||||
remote = origin
|
|
||||||
merge = refs/heads/master
|
|
||||||
[branch "other_branch"]
|
|
||||||
remote = origin
|
|
||||||
merge = refs/heads/other_branch
|
|
|
@ -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 75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 CI <CI@example.com> 1648352761 +1100 commit (initial): myfile1
|
|
||||||
75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 CI <CI@example.com> 1648352761 +1100 checkout: moving from master to other_branch
|
|
||||||
75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 CI <CI@example.com> 1648352761 +1100 checkout: moving from other_branch to master
|
|
|
@ -1 +0,0 @@
|
||||||
0000000000000000000000000000000000000000 75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 CI <CI@example.com> 1648352761 +1100 commit (initial): myfile1
|
|
|
@ -1 +0,0 @@
|
||||||
0000000000000000000000000000000000000000 75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 CI <CI@example.com> 1648352761 +1100 branch: Created from HEAD
|
|
|
@ -1 +0,0 @@
|
||||||
0000000000000000000000000000000000000000 75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27 CI <CI@example.com> 1648352761 +1100 fetch origin: storing head
|
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
||||||
x<01>ÍA
|
|
||||||
Â0@Q×9ÅìɤÓI¡«cšL°Ð!R"èííÜ~üÜÌÖH|ê»*xå\½ð¯š
|
|
||||||
‘bâ’0ÖH
…©Jƒ“w¶¦nÓüÐ<C3BC>ØkÓKnvdJÃ"#œ½wG=&]ÿäξuÝÝ2Ž,Ï
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
# pack-refs with: peeled fully-peeled sorted
|
|
|
@ -1 +0,0 @@
|
||||||
75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27
|
|
|
@ -1 +0,0 @@
|
||||||
75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27
|
|
|
@ -1 +0,0 @@
|
||||||
75f37fc5ae7e9967e9833b66beb2c9ee2f9f6c27
|
|
|
@ -1 +0,0 @@
|
||||||
test1
|
|
|
@ -1 +0,0 @@
|
||||||
{"KeyEvents":[{"Timestamp":608,"Mod":0,"Key":256,"Ch":102},{"Timestamp":1568,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]}
|
|
|
@ -1,34 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
cd $1
|
|
||||||
|
|
||||||
git init
|
|
||||||
|
|
||||||
git config user.email "CI@example.com"
|
|
||||||
git config user.name "CI"
|
|
||||||
|
|
||||||
# we're setting this to ensure that it's honoured by the fetch command
|
|
||||||
git config fetch.prune true
|
|
||||||
|
|
||||||
echo test1 > myfile1
|
|
||||||
git add .
|
|
||||||
git commit -am "myfile1"
|
|
||||||
|
|
||||||
git checkout -b other_branch
|
|
||||||
git checkout master
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
git clone --bare ./repo origin
|
|
||||||
|
|
||||||
cd repo
|
|
||||||
|
|
||||||
git remote add origin ../origin
|
|
||||||
git fetch origin
|
|
||||||
git branch --set-upstream-to=origin/master master
|
|
||||||
git branch --set-upstream-to=origin/other_branch other_branch
|
|
||||||
|
|
||||||
# unbenownst to our test repo we're removing the branch on the remote, so upon
|
|
||||||
# fetching with prune: true we expect git to realise the remote branch is gone
|
|
||||||
git -C ../origin branch -d other_branch
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"description": "fetch from the remote with the 'prune' option set in the git config. Note this has a false positive until we find a way to show ls-remote origin in all tests when creating snapshots.",
|
|
||||||
"speed": 10
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue