mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
allow copying commit author to clipboard
This commit is contained in:
parent
d85f4792af
commit
4dd09ee0d5
4 changed files with 55 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
)
|
||||
|
||||
|
@ -80,6 +81,27 @@ func (self *CommitCommands) GetCommitDiff(commitSha string) (string, error) {
|
|||
return diff, err
|
||||
}
|
||||
|
||||
type Author struct {
|
||||
Name string
|
||||
Email string
|
||||
}
|
||||
|
||||
func (self *CommitCommands) GetCommitAuthor(commitSha string) (Author, error) {
|
||||
cmdStr := "git show --no-patch --pretty=format:'%an|%ae' " + commitSha
|
||||
output, err := self.cmd.New(cmdStr).DontLog().RunWithOutput()
|
||||
if err != nil {
|
||||
return Author{}, err
|
||||
}
|
||||
|
||||
split := strings.Split(strings.TrimSpace(output), "|")
|
||||
if len(split) < 2 {
|
||||
return Author{}, errors.New("unexpected git output")
|
||||
}
|
||||
|
||||
author := Author{Name: split[0], Email: split[1]}
|
||||
return author, err
|
||||
}
|
||||
|
||||
func (self *CommitCommands) GetCommitMessageFirstLine(sha string) (string, error) {
|
||||
return self.GetCommitMessagesFirstLine([]string{sha})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue