Skip to content

Commit 31fcec1

Browse files
Merge pull request #2429 from stefanhaller/do-not-autosquash-in-regular-rebase
2 parents 0d395e4 + 1da762c commit 31fcec1

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

pkg/commands/git_commands/rebase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo
129129
debug = "TRUE"
130130
}
131131

132-
cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty %s", baseSha)
132+
cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty --no-autosquash %s", baseSha)
133133
self.Log.WithField("command", cmdStr).Debug("RunCommand")
134134

135135
cmdObj := self.cmd.New(cmdStr)

pkg/commands/git_commands/rebase_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestRebaseRebaseBranch(t *testing.T) {
2626
testName: "successful rebase",
2727
arg: "master",
2828
runner: oscommands.NewFakeRunner(t).
29-
Expect(`git rebase --interactive --autostash --keep-empty master`, "", nil),
29+
Expect(`git rebase --interactive --autostash --keep-empty --no-autosquash master`, "", nil),
3030
test: func(err error) {
3131
assert.NoError(t, err)
3232
},
@@ -35,7 +35,7 @@ func TestRebaseRebaseBranch(t *testing.T) {
3535
testName: "unsuccessful rebase",
3636
arg: "master",
3737
runner: oscommands.NewFakeRunner(t).
38-
Expect(`git rebase --interactive --autostash --keep-empty master`, "", errors.New("error")),
38+
Expect(`git rebase --interactive --autostash --keep-empty --no-autosquash master`, "", errors.New("error")),
3939
test: func(err error) {
4040
assert.Error(t, err)
4141
},
@@ -125,7 +125,7 @@ func TestRebaseDiscardOldFileChanges(t *testing.T) {
125125
commitIndex: 0,
126126
fileName: "test999.txt",
127127
runner: oscommands.NewFakeRunner(t).
128-
Expect(`git rebase --interactive --autostash --keep-empty abcdef`, "", nil).
128+
Expect(`git rebase --interactive --autostash --keep-empty --no-autosquash abcdef`, "", nil).
129129
Expect(`git cat-file -e HEAD^:"test999.txt"`, "", nil).
130130
Expect(`git checkout HEAD^ -- "test999.txt"`, "", nil).
131131
Expect(`git commit --amend --no-edit --allow-empty`, "", nil).
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package branch
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var RebaseDoesNotAutosquash = NewIntegrationTest(NewIntegrationTestArgs{
9+
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.",
10+
ExtraCmdArgs: "",
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.SetConfig("rebase.autoSquash", "true")
15+
16+
shell.
17+
EmptyCommit("base").
18+
NewBranch("my-branch").
19+
Checkout("master").
20+
EmptyCommit("master commit").
21+
Checkout("my-branch").
22+
EmptyCommit("branch commit").
23+
EmptyCommit("fixup! branch commit")
24+
},
25+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
26+
t.Views().Commits().
27+
Lines(
28+
Contains("fixup! branch commit"),
29+
Contains("branch commit"),
30+
Contains("base"),
31+
)
32+
33+
t.Views().Branches().
34+
Focus().
35+
Lines(
36+
Contains("my-branch").IsSelected(),
37+
Contains("master"),
38+
).
39+
SelectNextItem().
40+
Press(keys.Branches.RebaseBranch)
41+
42+
t.ExpectPopup().Confirmation().
43+
Title(Equals("Rebasing")).
44+
Content(Contains("Are you sure you want to rebase 'my-branch' on top of 'master'?")).
45+
Confirm()
46+
47+
t.Views().Commits().Lines(
48+
Contains("fixup! branch commit"),
49+
Contains("branch commit"),
50+
Contains("master commit"),
51+
Contains("base"),
52+
)
53+
},
54+
})

pkg/integration/tests/tests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var tests = []*components.IntegrationTest{
3838
branch.Delete,
3939
branch.Rebase,
4040
branch.RebaseAndDrop,
41+
branch.RebaseDoesNotAutosquash,
4142
branch.Suggestions,
4243
branch.Reset,
4344
branch.DetachedHead,

0 commit comments

Comments
 (0)