mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
Merge pull request #2164 from mark2185/fix-rebasing-over-merge-commits
This commit is contained in:
commit
092363a986
@ -255,7 +255,7 @@ func (self *RebaseCommands) SquashAllAboveFixupCommits(sha string) error {
|
||||
return self.runSkipEditorCommand(
|
||||
self.cmd.New(
|
||||
fmt.Sprintf(
|
||||
"git rebase --interactive --autostash --autosquash %s^",
|
||||
"git rebase --interactive --rebase-merges --autostash --autosquash %s^",
|
||||
sha,
|
||||
),
|
||||
),
|
||||
|
@ -76,6 +76,12 @@ func (self *Input) Confirm() {
|
||||
self.pressKey(self.keys.Universal.Confirm)
|
||||
}
|
||||
|
||||
func (self *Input) ProceedWhenAsked(matcher *matcher) {
|
||||
self.assert.InConfirm()
|
||||
self.assert.MatchCurrentViewContent(matcher)
|
||||
self.Confirm()
|
||||
}
|
||||
|
||||
// i.e. same as Confirm
|
||||
func (self *Input) Enter() {
|
||||
self.pressKey(self.keys.Universal.Confirm)
|
||||
|
@ -63,6 +63,10 @@ func (s *Shell) Checkout(name string) *Shell {
|
||||
return s.RunCommand("git checkout " + name)
|
||||
}
|
||||
|
||||
func (s *Shell) Merge(name string) *Shell {
|
||||
return s.RunCommand("git merge --commit --no-ff " + name)
|
||||
}
|
||||
|
||||
func (s *Shell) GitAdd(path string) *Shell {
|
||||
return s.RunCommand(fmt.Sprintf("git add \"%s\"", path))
|
||||
}
|
||||
|
50
pkg/integration/tests/interactive_rebase/amend_merge.go
Normal file
50
pkg/integration/tests/interactive_rebase/amend_merge.go
Normal file
@ -0,0 +1,50 @@
|
||||
package interactive_rebase
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var (
|
||||
postMergeFileContent = "post merge file content"
|
||||
postMergeFilename = "post-merge-file"
|
||||
)
|
||||
|
||||
var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Amends a staged file to a merge commit.",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.
|
||||
NewBranch("development-branch").
|
||||
CreateFileAndAdd("initial-file", "initial file content").
|
||||
Commit("initial commit").
|
||||
NewBranch("feature-branch"). // it's also checked out automatically
|
||||
CreateFileAndAdd("new-feature-file", "new content").
|
||||
Commit("new feature commit").
|
||||
Checkout("development-branch").
|
||||
Merge("feature-branch").
|
||||
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(3)
|
||||
|
||||
input.SwitchToCommitsWindow()
|
||||
assert.CurrentViewName("commits")
|
||||
|
||||
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
|
||||
assert.MatchHeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
input.PressKeys(keys.Commits.AmendToCommit)
|
||||
input.ProceedWhenAsked(Contains("Are you sure you want to amend this commit with your staged files?"))
|
||||
|
||||
// assuring we haven't added a brand new commit
|
||||
assert.CommitCount(3)
|
||||
assert.MatchHeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
// assuring the post-merge file shows up in the merge commit.
|
||||
assert.MatchMainViewContent(Contains(postMergeFilename))
|
||||
assert.MatchMainViewContent(Contains("++" + postMergeFileContent))
|
||||
},
|
||||
})
|
@ -29,6 +29,7 @@ var tests = []*components.IntegrationTest{
|
||||
branch.Rebase,
|
||||
branch.RebaseAndDrop,
|
||||
interactive_rebase.One,
|
||||
interactive_rebase.AmendMerge,
|
||||
custom_commands.Basic,
|
||||
custom_commands.MultiplePrompts,
|
||||
custom_commands.MenuFromCommand,
|
||||
|
@ -0,0 +1 @@
|
||||
fixup! Merge branch 'feature-branch' into development-branch
|
@ -0,0 +1 @@
|
||||
ref: refs/heads/development-branch
|
@ -0,0 +1 @@
|
||||
7802c86c6ce62289e32aa13d0c85dc3f733195cb
|
@ -0,0 +1,12 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
||||
[user]
|
||||
email = CI@example.com
|
||||
name = CI
|
||||
[commit]
|
||||
gpgSign = false
|
@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
# 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
|
@ -0,0 +1,12 @@
|
||||
0000000000000000000000000000000000000000 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 CI <CI@example.com> 1663440492 -0700 commit (initial): initial commit
|
||||
3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 CI <CI@example.com> 1663440492 -0700 checkout: moving from development-branch to feature-branch
|
||||
3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 d1c7801838f293fe8f4b49dae6b4919d0359e6e6 CI <CI@example.com> 1663440492 -0700 commit: new feature commit
|
||||
d1c7801838f293fe8f4b49dae6b4919d0359e6e6 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 CI <CI@example.com> 1663440492 -0700 checkout: moving from feature-branch to development-branch
|
||||
3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 f68c5b48c653ca6ab23abd7606fe8fa8cc8d5b15 CI <CI@example.com> 1663440492 -0700 merge feature-branch: Merge made by the 'recursive' strategy.
|
||||
f68c5b48c653ca6ab23abd7606fe8fa8cc8d5b15 7802c86c6ce62289e32aa13d0c85dc3f733195cb CI <CI@example.com> 1663440493 -0700 commit: fixup! Merge branch 'feature-branch' into development-branch
|
||||
7802c86c6ce62289e32aa13d0c85dc3f733195cb 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 CI <CI@example.com> 1663440494 -0700 rebase (start): checkout f68c5b48c653ca6ab23abd7606fe8fa8cc8d5b15^
|
||||
3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 d1c7801838f293fe8f4b49dae6b4919d0359e6e6 CI <CI@example.com> 1663440494 -0700 rebase: fast-forward
|
||||
d1c7801838f293fe8f4b49dae6b4919d0359e6e6 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 CI <CI@example.com> 1663440494 -0700 rebase (reset): 'onto'
|
||||
3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 f68c5b48c653ca6ab23abd7606fe8fa8cc8d5b15 CI <CI@example.com> 1663440494 -0700 rebase: fast-forward
|
||||
f68c5b48c653ca6ab23abd7606fe8fa8cc8d5b15 f517de66e2a158d4a1d85246611cae9ca23a938d CI <CI@example.com> 1663440494 -0700 rebase (fixup): Merge branch 'feature-branch' into development-branch
|
||||
f517de66e2a158d4a1d85246611cae9ca23a938d f517de66e2a158d4a1d85246611cae9ca23a938d CI <CI@example.com> 1663440494 -0700 rebase (finish): returning to refs/heads/development-branch
|
@ -0,0 +1,4 @@
|
||||
0000000000000000000000000000000000000000 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 CI <CI@example.com> 1663440492 -0700 commit (initial): initial commit
|
||||
3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 f68c5b48c653ca6ab23abd7606fe8fa8cc8d5b15 CI <CI@example.com> 1663440492 -0700 merge feature-branch: Merge made by the 'recursive' strategy.
|
||||
f68c5b48c653ca6ab23abd7606fe8fa8cc8d5b15 7802c86c6ce62289e32aa13d0c85dc3f733195cb CI <CI@example.com> 1663440493 -0700 commit: fixup! Merge branch 'feature-branch' into development-branch
|
||||
7802c86c6ce62289e32aa13d0c85dc3f733195cb f517de66e2a158d4a1d85246611cae9ca23a938d CI <CI@example.com> 1663440494 -0700 rebase (finish): refs/heads/development-branch onto 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3
|
@ -0,0 +1,2 @@
|
||||
0000000000000000000000000000000000000000 3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 CI <CI@example.com> 1663440492 -0700 branch: Created from HEAD
|
||||
3ad14f8b4ed479f2fd9d8d4f7fe2a9913771b7f3 d1c7801838f293fe8f4b49dae6b4919d0359e6e6 CI <CI@example.com> 1663440492 -0700 commit: new feature commit
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
xŤŽMjĂ0F»Ö)¦«¬R$ë×J «,z�Ńx¦1D–rČńkh�ĺűŢ·xTK™;.~ôĆÖŤÝ %k!˛"ŃiFöyśČh‹fĆűÄjĹĆK ‰|v‰‚·„ó`1O1č śQš|6^áÖoµÁĺ
|
||||
§ËőĚO,ëťż¨–o0!Xç´-uÔZíëŐůÍ»’ůąźđĂí—!7\čaě[ăă?`^z…‰|ŻkŮÓ_BýśîNš
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
x…�¹jADïWt¦HfŽÞ9@ƒ"þˆ9ª-�fwFÆŸï˱£¢ª^òÊÚÚm� áet€,Gx6J²’R¬ˆg…„9ÇZ´²I§ç9`ÚRÇ2ȦªYBfTöQŒÔXCeñ“bÔÖ{�½Ø?¾êâƒÒÁ1Ñ
|
||||
‚pæXÜ:Veç7¥Ç¸®�Î:�/ïøNm»ãµ¬í�´s–Yq4tT^©i_w‰�p~âÓú'(÷´”+i<:Ž¿ý@·e¬Tñ…ûºµÝñyL?2#Y|
|
@ -0,0 +1,2 @@
|
||||
xŤŹ»jC1DS߯ŘΕ�kiB¸r‘Ź�´»±Á÷��C>?’ô©†™9Íië<ߢ§ŃU!WÁ4&Gµ™ŞŃ)#5vĺ¤Í{´šĎÓVş.b‘}˘Š*�Ů‚ Z6
…ŮÇś}Í˙xń-“óÉGS2¬ČR4íáY\<±&MSyŚëÚá|�—óĺMżĘĽÝőąó+ř”"˘CptŮąi_w‰ˇ˙ħwí
|
||||
µ—Ą]á`ZĆŁëń§ŕ¶ŚD?őľnóîř{Lßr[Y»
|
@ -0,0 +1 @@
|
||||
f517de66e2a158d4a1d85246611cae9ca23a938d
|
@ -0,0 +1 @@
|
||||
d1c7801838f293fe8f4b49dae6b4919d0359e6e6
|
@ -0,0 +1 @@
|
||||
initial file content
|
@ -0,0 +1 @@
|
||||
new content
|
@ -0,0 +1 @@
|
||||
post merge file content
|
Loading…
Reference in New Issue
Block a user