Files
lazygit/pkg/integration/tests/commit/commit_during_squash_merge.go
Stefan HallerandClaude Opus 5.5 09780de32e Use the squash merge message when committing a squash merge
After "Squash merge and leave uncommitted", the commit panel opens
empty, or with the commit prefix of the branch. Users have to type a
message for the squash merge themselves. "git commit" from the terminal
suggests the message in SQUASH_MSG instead.

Show the message in SQUASH_MSG in the commit panel, unless there is a
preserved message. It takes precedence over the commit prefix, like the
message of "Squash merge and commit" does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:36:41 +01:00

59 lines
1.6 KiB
Go

package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CommitDuringSquashMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Commit the changes of a squash merge that was left uncommitted, using the squash merge message",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
cfg.GetUserConfig().Git.CommitPrefix = []config.CommitPrefixConfig{{Pattern: "^(\\w+)-branch$", Replace: "[$1] "}}
},
SetupRepo: func(shell *Shell) {
shell.NewBranch("original-branch").
EmptyCommit("one").
NewBranch("feature-branch").
CreateFileAndAdd("feature-file", "content").
Commit("feature").
Checkout("original-branch")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Lines(
Contains("original-branch").IsSelected(),
Contains("feature-branch"),
).
SelectNextItem().
Press(keys.Branches.MergeIntoCurrentBranch)
t.ExpectPopup().Menu().
Title(Equals("Merge")).
Select(Contains("Squash merge and leave uncommitted")).
Confirm()
t.Views().Files().
Focus().
Lines(
Equals("A feature-file"),
).
Press(keys.Files.CommitChanges)
t.ExpectPopup().CommitMessagePanel().
Title(Equals("Commit summary")).
InitialText(Equals("Squash merge feature-branch into original-branch")).
Confirm()
t.Views().Status().Content(Equals("repo → original-branch"))
t.Views().Commits().
Lines(
Contains("Squash merge feature-branch into original-branch"),
Contains("one"),
)
},
})