Files
lazygit/pkg/integration/tests/commit/copy_commit_message_from_panel.go
Stefan HallerandClaude Opus 5.5 5a5e3ac696 Add "Copy commit message to clipboard" to the commit menu
The commit menu (ctrl+o in the commit message panel) can paste a message
from the clipboard, but it can't copy the message to it. Copying is
useful for keeping a message around while committing something else
first. For example, if a pre-commit hook fails, users may want to
commit a fix for it before they come back to the original change. If
they commit the fix through the commit message panel, lazygit deletes
the preserved message of the original change.

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

45 lines
1.4 KiB
Go

package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CopyCommitMessageFromPanel = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Copy the commit message from the commit message panel to the clipboard",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > ../clipboard"
},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "file content")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
Focus().
Press(keys.Files.CommitChanges)
t.ExpectPopup().CommitMessagePanel().
Type("subject").
SwitchToDescription().
Type("This line is longer than the auto-wrap width, so the clipboard gets it with a line break").
AddNewline().
Type("second line").
SwitchToSummary().
OpenCommitMenu()
t.ExpectPopup().Menu().Title(Equals("Commit Menu")).
Select(Contains("Copy commit message to clipboard")).
Confirm()
t.ExpectToast(Equals("Commit message copied to clipboard"))
t.FileSystem().FileContent("../clipboard", Equals(
"subject\n\nThis line is longer than the auto-wrap width, so the clipboard gets it\nwith a line break\nsecond line"))
t.ExpectPopup().CommitMessagePanel().
Content(Equals("subject"))
},
})