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

migrate more force push tests

This commit is contained in:
Jesse Duffield 2023-02-19 13:51:45 +11:00
parent 7201a91b69
commit 76a1b501f2
109 changed files with 126 additions and 307 deletions

View File

@ -0,0 +1,53 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ForcePushMultipleMatching = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Force push to multiple branches because the user has push.default matching",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
shell.SetConfig("push.default", "matching")
createTwoBranchesReadyToForcePush(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("one"),
)
t.Views().Status().Content(Contains("↓1 repo → master"))
t.Views().Branches().
Lines(
Contains("master ↓1"),
Contains("other_branch ↓1"),
)
t.Views().Files().IsFocused().Press(keys.Universal.Push)
t.ExpectPopup().Confirmation().
Title(Equals("Force push")).
Content(Equals("Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.")).
Confirm()
t.Views().Commits().
Lines(
Contains("one"),
)
t.Views().Status().Content(Contains("✓ repo → master"))
t.Views().Branches().
Lines(
Contains("master ✓"),
Contains("other_branch ✓"),
)
},
})

View File

@ -0,0 +1,71 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
func createTwoBranchesReadyToForcePush(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.NewBranch("other_branch")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.SetBranchUpstream("other_branch", "origin/other_branch")
// remove the 'two' commit so that we have something to pull from the remote
shell.HardReset("HEAD^")
shell.Checkout("master")
// doing the same for master
shell.HardReset("HEAD^")
}
var ForcePushMultipleUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Force push to only the upstream branch of the current branch because the user has push.default upstream",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.SetConfig("push.default", "upstream")
createTwoBranchesReadyToForcePush(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("one"),
)
t.Views().Status().Content(Contains("↓1 repo → master"))
t.Views().Branches().
Lines(
Contains("master ↓1"),
Contains("other_branch ↓1"),
)
t.Views().Files().IsFocused().Press(keys.Universal.Push)
t.ExpectPopup().Confirmation().
Title(Equals("Force push")).
Content(Equals("Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.")).
Confirm()
t.Views().Commits().
Lines(
Contains("one"),
)
t.Views().Status().Content(Contains("✓ repo → master"))
t.Views().Branches().
Lines(
Contains("master ✓"),
Contains("other_branch ↓1"),
)
},
})

View File

@ -73,6 +73,8 @@ var tests = []*components.IntegrationTest{
submodule.Reset,
sync.FetchPrune,
sync.ForcePush,
sync.ForcePushMultipleMatching,
sync.ForcePushMultipleUpstream,
sync.Pull,
sync.PullAndSetUpstream,
sync.RenameBranchAndPull,

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/forcePushMultiple/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�ÍA
ƒ0@Ñ®sŠÙJ&NÇ¥\yŒ1™PÁ!ERÐÛ×#tûyðS5[ ñ¥mªà•SñÂs?hÌDŠ‘sÄ Xzš©ËLEÒ=8ù¶wÝ`œà1N/ÝÅ>«ÞRµ' Sìh €pEôÞ�õœ4ý“;;ʲ*º2K,Í

View File

@ -1,3 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
e67f344f42afdb79c87a590f22537160241d8d61 refs/heads/master
e67f344f42afdb79c87a590f22537160241d8d61 refs/heads/other_branch

View File

@ -1 +0,0 @@
e67f344f42afdb79c87a590f22537160241d8d61

View File

@ -1 +0,0 @@
e67f344f42afdb79c87a590f22537160241d8d61

View File

@ -1,2 +0,0 @@
bd739fb752ed02ccd49422196e31599c87ff90ad branch 'master' of ../origin
fe67c3eaf819025990d3688d5f147a064e669ca5 not-for-merge branch 'other_branch' of ../origin

View File

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

View File

@ -1 +0,0 @@
fe67c3eaf819025990d3688d5f147a064e669ca5

View File

@ -1,21 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[user]
email = CI@example.com
name = CI
[push]
default = matching
[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

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,10 +0,0 @@
0000000000000000000000000000000000000000 7a35f0bb6bd8dc18ae462465e51f02362ba6babe CI <CI@example.com> 1648349421 +1100 commit (initial): myfile1
7a35f0bb6bd8dc18ae462465e51f02362ba6babe e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 commit: myfile2
e67f344f42afdb79c87a590f22537160241d8d61 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 checkout: moving from master to other_branch
e67f344f42afdb79c87a590f22537160241d8d61 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 checkout: moving from other_branch to master
e67f344f42afdb79c87a590f22537160241d8d61 bd739fb752ed02ccd49422196e31599c87ff90ad CI <CI@example.com> 1648349421 +1100 commit: myfile3
bd739fb752ed02ccd49422196e31599c87ff90ad e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 reset: moving to HEAD^
e67f344f42afdb79c87a590f22537160241d8d61 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 checkout: moving from master to other_branch
e67f344f42afdb79c87a590f22537160241d8d61 fe67c3eaf819025990d3688d5f147a064e669ca5 CI <CI@example.com> 1648349421 +1100 commit: myfile4
fe67c3eaf819025990d3688d5f147a064e669ca5 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349422 +1100 reset: moving to HEAD^
e67f344f42afdb79c87a590f22537160241d8d61 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349422 +1100 checkout: moving from other_branch to master

View File

@ -1,4 +0,0 @@
0000000000000000000000000000000000000000 7a35f0bb6bd8dc18ae462465e51f02362ba6babe CI <CI@example.com> 1648349421 +1100 commit (initial): myfile1
7a35f0bb6bd8dc18ae462465e51f02362ba6babe e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 commit: myfile2
e67f344f42afdb79c87a590f22537160241d8d61 bd739fb752ed02ccd49422196e31599c87ff90ad CI <CI@example.com> 1648349421 +1100 commit: myfile3
bd739fb752ed02ccd49422196e31599c87ff90ad e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 reset: moving to HEAD^

View File

@ -1,3 +0,0 @@
0000000000000000000000000000000000000000 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 branch: Created from HEAD
e67f344f42afdb79c87a590f22537160241d8d61 fe67c3eaf819025990d3688d5f147a064e669ca5 CI <CI@example.com> 1648349421 +1100 commit: myfile4
fe67c3eaf819025990d3688d5f147a064e669ca5 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349422 +1100 reset: moving to HEAD^

View File

@ -1,3 +0,0 @@
0000000000000000000000000000000000000000 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 fetch origin: storing head
e67f344f42afdb79c87a590f22537160241d8d61 bd739fb752ed02ccd49422196e31599c87ff90ad CI <CI@example.com> 1648349421 +1100 update by push
bd739fb752ed02ccd49422196e31599c87ff90ad e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349423 +1100 update by push

View File

@ -1,3 +0,0 @@
0000000000000000000000000000000000000000 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349421 +1100 fetch origin: storing head
e67f344f42afdb79c87a590f22537160241d8d61 fe67c3eaf819025990d3688d5f147a064e669ca5 CI <CI@example.com> 1648349421 +1100 update by push
fe67c3eaf819025990d3688d5f147a064e669ca5 e67f344f42afdb79c87a590f22537160241d8d61 CI <CI@example.com> 1648349423 +1100 update by push

View File

@ -1,2 +0,0 @@
x�ÍA
ƒ0@Ñ®sŠÙJ&NÇ¥\yŒ1™PÁ!ERÐÛ×#tûyðS5[ ñ¥mªà•SñÂs?hÌDŠ‘sÄ Xzš©ËLEÒ=8ù¶wÝ`œà1N/ÝÅ>«ÞRµ' Sìh €pEôÞ�õœ4ý“;;ʲ*º2K,Í

View File

@ -1 +0,0 @@
e67f344f42afdb79c87a590f22537160241d8d61

View File

@ -1 +0,0 @@
e67f344f42afdb79c87a590f22537160241d8d61

View File

@ -1 +0,0 @@
e67f344f42afdb79c87a590f22537160241d8d61

View File

@ -1 +0,0 @@
e67f344f42afdb79c87a590f22537160241d8d61

View File

@ -1 +0,0 @@
{"KeyEvents":[{"Timestamp":892,"Mod":0,"Key":256,"Ch":80},{"Timestamp":1379,"Mod":0,"Key":13,"Ch":13},{"Timestamp":2132,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":135,"Height":36}]}

View File

@ -1,54 +0,0 @@
#!/bin/sh
set -e
set -e
cd $1
git init
git config user.email "CI@example.com"
git config user.name "CI"
git config push.default matching
echo test1 > myfile1
git add .
git commit -am "myfile1"
echo test2 > myfile2
git add .
git commit -am "myfile2"
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
echo test3 > myfile3
git add .
git commit -am "myfile3"
git push origin master
git reset --hard HEAD^
git checkout other_branch
echo test4 > myfile4
git add .
git commit -am "myfile4"
git push origin other_branch
git reset --hard HEAD^
git checkout master
# at this point, both branches have diverged from their remote counterparts, meaning if you
# attempt to push either, it'll ask if you want to force push.

View File

@ -1,4 +0,0 @@
{
"description": "Force push to multiple branches because the user has push.default matching",
"speed": 10
}

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/forcePushMultipleUpstream/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,3 +0,0 @@
x�ÍA
ƒ0@Ñ®sŠÙJ&Žc„R
®<ƘL¨à‘ÚÛ×#tûyðS5[ ñ¥ªà•SñÂË0jÌDŠ‘sÄ XZ¨ËLERœ¼Û«0ÍpŸæ§~ÄöMo©Ú�)v4öàŠè½;ë9iú'wö-ë¦è~3—,Õ

View File

@ -1,5 +0,0 @@
x�ÎM
ƒ0@á®sŠì %“óR
®<Æ8N¨`ªH
ííëº}|‹'[­K³�éÒU+ê¥ 9v> rô2uÓ\8„0e•™C2;új–²2QAˆÙù”ÑIRt `ÌÄð»=·Ã£í‡ñ¡®ûª7ÙêÝB „”;òö
àœ9ë9ÕôOnê·,«’ù‚ 9—

View File

@ -1,3 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
49ea44f3ec1792142714930c8e4c3073f137936c refs/heads/master
49ea44f3ec1792142714930c8e4c3073f137936c refs/heads/other_branch

View File

@ -1 +0,0 @@
49ea44f3ec1792142714930c8e4c3073f137936c

View File

@ -1 +0,0 @@
c84375dda9d81c1f2103defe4384e31f859dac86

View File

@ -1,2 +0,0 @@
486301f318c84045827013a3c3246b8c6a319eb8 branch 'master' of ../origin
c84375dda9d81c1f2103defe4384e31f859dac86 not-for-merge branch 'other_branch' of ../origin

View File

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

View File

@ -1 +0,0 @@
c84375dda9d81c1f2103defe4384e31f859dac86

View File

@ -1,21 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[user]
email = CI@example.com
name = CI
[push]
default = upstream
[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

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,10 +0,0 @@
0000000000000000000000000000000000000000 81bdc116083cd4b4655333f4eb94dc0320197082 CI <CI@example.com> 1648349542 +1100 commit (initial): myfile1
81bdc116083cd4b4655333f4eb94dc0320197082 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 commit: myfile2
49ea44f3ec1792142714930c8e4c3073f137936c 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 checkout: moving from master to other_branch
49ea44f3ec1792142714930c8e4c3073f137936c 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 checkout: moving from other_branch to master
49ea44f3ec1792142714930c8e4c3073f137936c 486301f318c84045827013a3c3246b8c6a319eb8 CI <CI@example.com> 1648349542 +1100 commit: myfile3
486301f318c84045827013a3c3246b8c6a319eb8 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 reset: moving to HEAD^
49ea44f3ec1792142714930c8e4c3073f137936c 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 checkout: moving from master to other_branch
49ea44f3ec1792142714930c8e4c3073f137936c c84375dda9d81c1f2103defe4384e31f859dac86 CI <CI@example.com> 1648349542 +1100 commit: myfile4
c84375dda9d81c1f2103defe4384e31f859dac86 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 reset: moving to HEAD^
49ea44f3ec1792142714930c8e4c3073f137936c 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 checkout: moving from other_branch to master

View File

@ -1,4 +0,0 @@
0000000000000000000000000000000000000000 81bdc116083cd4b4655333f4eb94dc0320197082 CI <CI@example.com> 1648349542 +1100 commit (initial): myfile1
81bdc116083cd4b4655333f4eb94dc0320197082 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 commit: myfile2
49ea44f3ec1792142714930c8e4c3073f137936c 486301f318c84045827013a3c3246b8c6a319eb8 CI <CI@example.com> 1648349542 +1100 commit: myfile3
486301f318c84045827013a3c3246b8c6a319eb8 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 reset: moving to HEAD^

View File

@ -1,3 +0,0 @@
0000000000000000000000000000000000000000 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 branch: Created from HEAD
49ea44f3ec1792142714930c8e4c3073f137936c c84375dda9d81c1f2103defe4384e31f859dac86 CI <CI@example.com> 1648349542 +1100 commit: myfile4
c84375dda9d81c1f2103defe4384e31f859dac86 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 reset: moving to HEAD^

View File

@ -1,3 +0,0 @@
0000000000000000000000000000000000000000 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 fetch origin: storing head
49ea44f3ec1792142714930c8e4c3073f137936c 486301f318c84045827013a3c3246b8c6a319eb8 CI <CI@example.com> 1648349542 +1100 update by push
486301f318c84045827013a3c3246b8c6a319eb8 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349543 +1100 update by push

View File

@ -1,2 +0,0 @@
0000000000000000000000000000000000000000 49ea44f3ec1792142714930c8e4c3073f137936c CI <CI@example.com> 1648349542 +1100 fetch origin: storing head
49ea44f3ec1792142714930c8e4c3073f137936c c84375dda9d81c1f2103defe4384e31f859dac86 CI <CI@example.com> 1648349542 +1100 update by push

View File

@ -1,3 +0,0 @@
x�ÍA
ƒ0@Ñ®sŠÙJ&Žc„R
®<ƘL¨à‘ÚÛ×#tûyðS5[ ñ¥ªà•SñÂË0jÌDŠ‘sÄ XZ¨ËLERœ¼Û«0ÍpŸæ§~ÄöMo©Ú�)v4öàŠè½;ë9iú'wö-ë¦è~3—,Õ

View File

@ -1,5 +0,0 @@
x�ÎM
ƒ0@á®sŠì %“óR
®<Æ8N¨`ªH
ííëº}|‹'[­K³�éÒU+ê¥ 9v> rô2uÓ\8„0e•™C2;új–²2QAˆÙù”ÑIRt `ÌÄð»=·Ã£í‡ñ¡®ûª7ÙêÝB „”;òö
àœ9ë9ÕôOnê·,«’ù‚ 9—

Some files were not shown because too many files have changed in this diff Show More