mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-17 22:32:58 +02:00
Merge pull request #2429 from stefanhaller/do-not-autosquash-in-regular-rebase
This commit is contained in:
commit
31fcec16d9
@ -129,7 +129,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo
|
|||||||
debug = "TRUE"
|
debug = "TRUE"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty %s", baseSha)
|
cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty --no-autosquash %s", baseSha)
|
||||||
self.Log.WithField("command", cmdStr).Debug("RunCommand")
|
self.Log.WithField("command", cmdStr).Debug("RunCommand")
|
||||||
|
|
||||||
cmdObj := self.cmd.New(cmdStr)
|
cmdObj := self.cmd.New(cmdStr)
|
||||||
|
@ -26,7 +26,7 @@ func TestRebaseRebaseBranch(t *testing.T) {
|
|||||||
testName: "successful rebase",
|
testName: "successful rebase",
|
||||||
arg: "master",
|
arg: "master",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git rebase --interactive --autostash --keep-empty master`, "", nil),
|
Expect(`git rebase --interactive --autostash --keep-empty --no-autosquash master`, "", nil),
|
||||||
test: func(err error) {
|
test: func(err error) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
@ -35,7 +35,7 @@ func TestRebaseRebaseBranch(t *testing.T) {
|
|||||||
testName: "unsuccessful rebase",
|
testName: "unsuccessful rebase",
|
||||||
arg: "master",
|
arg: "master",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git rebase --interactive --autostash --keep-empty master`, "", errors.New("error")),
|
Expect(`git rebase --interactive --autostash --keep-empty --no-autosquash master`, "", errors.New("error")),
|
||||||
test: func(err error) {
|
test: func(err error) {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
},
|
},
|
||||||
@ -125,7 +125,7 @@ func TestRebaseDiscardOldFileChanges(t *testing.T) {
|
|||||||
commitIndex: 0,
|
commitIndex: 0,
|
||||||
fileName: "test999.txt",
|
fileName: "test999.txt",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git rebase --interactive --autostash --keep-empty abcdef`, "", nil).
|
Expect(`git rebase --interactive --autostash --keep-empty --no-autosquash abcdef`, "", nil).
|
||||||
Expect(`git cat-file -e HEAD^:"test999.txt"`, "", nil).
|
Expect(`git cat-file -e HEAD^:"test999.txt"`, "", nil).
|
||||||
Expect(`git checkout HEAD^ -- "test999.txt"`, "", nil).
|
Expect(`git checkout HEAD^ -- "test999.txt"`, "", nil).
|
||||||
Expect(`git commit --amend --no-edit --allow-empty`, "", nil).
|
Expect(`git commit --amend --no-edit --allow-empty`, "", nil).
|
||||||
|
54
pkg/integration/tests/branch/rebase_does_not_autosquash.go
Normal file
54
pkg/integration/tests/branch/rebase_does_not_autosquash.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package branch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RebaseDoesNotAutosquash = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Rebase a branch that has fixups onto another branch, and verify that the fixups are not squashed even if rebase.autoSquash is enabled globally.",
|
||||||
|
ExtraCmdArgs: "",
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.SetConfig("rebase.autoSquash", "true")
|
||||||
|
|
||||||
|
shell.
|
||||||
|
EmptyCommit("base").
|
||||||
|
NewBranch("my-branch").
|
||||||
|
Checkout("master").
|
||||||
|
EmptyCommit("master commit").
|
||||||
|
Checkout("my-branch").
|
||||||
|
EmptyCommit("branch commit").
|
||||||
|
EmptyCommit("fixup! branch commit")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Commits().
|
||||||
|
Lines(
|
||||||
|
Contains("fixup! branch commit"),
|
||||||
|
Contains("branch commit"),
|
||||||
|
Contains("base"),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.Views().Branches().
|
||||||
|
Focus().
|
||||||
|
Lines(
|
||||||
|
Contains("my-branch").IsSelected(),
|
||||||
|
Contains("master"),
|
||||||
|
).
|
||||||
|
SelectNextItem().
|
||||||
|
Press(keys.Branches.RebaseBranch)
|
||||||
|
|
||||||
|
t.ExpectPopup().Confirmation().
|
||||||
|
Title(Equals("Rebasing")).
|
||||||
|
Content(Contains("Are you sure you want to rebase 'my-branch' on top of 'master'?")).
|
||||||
|
Confirm()
|
||||||
|
|
||||||
|
t.Views().Commits().Lines(
|
||||||
|
Contains("fixup! branch commit"),
|
||||||
|
Contains("branch commit"),
|
||||||
|
Contains("master commit"),
|
||||||
|
Contains("base"),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
@ -38,6 +38,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
branch.Delete,
|
branch.Delete,
|
||||||
branch.Rebase,
|
branch.Rebase,
|
||||||
branch.RebaseAndDrop,
|
branch.RebaseAndDrop,
|
||||||
|
branch.RebaseDoesNotAutosquash,
|
||||||
branch.Suggestions,
|
branch.Suggestions,
|
||||||
branch.Reset,
|
branch.Reset,
|
||||||
branch.DetachedHead,
|
branch.DetachedHead,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user