Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/commands/git_commands/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ type Author struct {

func (self *CommitCommands) GetCommitAuthor(commitHash string) (Author, error) {
cmdArgs := NewGitCmd("show").
Arg("--no-patch", "--pretty=format:'%an%x00%ae'", commitHash).
Arg("--no-patch", "--pretty=format:%an%x00%ae", commitHash).
ToArgv()

output, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
Expand Down
48 changes: 48 additions & 0 deletions pkg/integration/tests/commit/copy_author_to_clipboard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package commit

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

// We're emulating the clipboard by writing to a file called clipboard

var CopyAuthorToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Copy a commit author name to the clipboard",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
// Include delimiters around the text so that we can assert on the entire content
config.GetUserConfig().OS.CopyToClipboardCmd = "echo /{{text}}/ > clipboard"
},

SetupRepo: func(shell *Shell) {
shell.SetAuthor("John Doe", "[email protected]")
shell.EmptyCommit("commit")
},

Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit").IsSelected(),
).
Press(keys.Commits.CopyCommitAttributeToClipboard)

t.ExpectPopup().Menu().
Title(Equals("Copy to clipboard")).
Select(Contains("Commit author")).
Confirm()

t.ExpectToast(Equals("Commit author copied to clipboard"))

t.Views().Files().
Focus().
Press(keys.Files.RefreshFiles).
Lines(
Contains("clipboard").IsSelected(),
)

t.Views().Main().Content(Contains("/John Doe <[email protected]>/"))
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var tests = []*components.IntegrationTest{
commit.CommitWithGlobalPrefix,
commit.CommitWithNonMatchingBranchName,
commit.CommitWithPrefix,
commit.CopyAuthorToClipboard,
commit.CreateAmendCommit,
commit.CreateFixupCommitInBranchStack,
commit.CreateTag,
Expand Down
Loading