mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
Add copy commit attributes option
This commit is contained in:
parent
bbaa651943
commit
540edb0bf4
@ -155,7 +155,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>g</kbd>: reset to this commit
|
<kbd>g</kbd>: reset to this commit
|
||||||
<kbd>space</kbd>: checkout commit
|
<kbd>space</kbd>: checkout commit
|
||||||
<kbd>T</kbd>: tag commit
|
<kbd>T</kbd>: tag commit
|
||||||
<kbd>ctrl+y</kbd>: copy commit message to clipboard
|
<kbd>y</kbd>: copy commit attribute
|
||||||
<kbd>o</kbd>: open commit in browser
|
<kbd>o</kbd>: open commit in browser
|
||||||
<kbd>enter</kbd>: view selected item's files
|
<kbd>enter</kbd>: view selected item's files
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -195,7 +195,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>g</kbd>: reset naar deze commit
|
<kbd>g</kbd>: reset naar deze commit
|
||||||
<kbd>space</kbd>: checkout commit
|
<kbd>space</kbd>: checkout commit
|
||||||
<kbd>T</kbd>: tag commit
|
<kbd>T</kbd>: tag commit
|
||||||
<kbd>ctrl+y</kbd>: kopieer commit bericht naar klembord
|
<kbd>y</kbd>: copy commit attribute
|
||||||
<kbd>o</kbd>: open commit in browser
|
<kbd>o</kbd>: open commit in browser
|
||||||
<kbd>enter</kbd>: bekijk gecommite bestanden
|
<kbd>enter</kbd>: bekijk gecommite bestanden
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -68,7 +68,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>g</kbd>: zresetuj do tego commita
|
<kbd>g</kbd>: zresetuj do tego commita
|
||||||
<kbd>space</kbd>: checkout commit
|
<kbd>space</kbd>: checkout commit
|
||||||
<kbd>T</kbd>: tag commit
|
<kbd>T</kbd>: tag commit
|
||||||
<kbd>ctrl+y</kbd>: copy commit message to clipboard
|
<kbd>y</kbd>: copy commit attribute
|
||||||
<kbd>o</kbd>: open commit in browser
|
<kbd>o</kbd>: open commit in browser
|
||||||
<kbd>enter</kbd>: przeglądaj pliki commita
|
<kbd>enter</kbd>: przeglądaj pliki commita
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -207,8 +207,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>g</kbd>: 重置为此提交
|
<kbd>g</kbd>: 重置为此提交
|
||||||
<kbd>space</kbd>: 检出提交
|
<kbd>space</kbd>: 检出提交
|
||||||
<kbd>T</kbd>: 标签提交
|
<kbd>T</kbd>: 标签提交
|
||||||
<kbd>ctrl+y</kbd>: 将提交消息复制到剪贴板
|
<kbd>y</kbd>: copy commit attribute
|
||||||
<kbd>o</kbd>: 在浏览器中打开提交
|
<kbd>o</kbd>: open commit in browser
|
||||||
<kbd>enter</kbd>: 查看提交的文件
|
<kbd>enter</kbd>: 查看提交的文件
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
@ -74,6 +74,12 @@ func (self *CommitCommands) GetCommitMessage(commitSha string) (string, error) {
|
|||||||
return strings.TrimSpace(message), err
|
return strings.TrimSpace(message), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *CommitCommands) GetCommitDiff(commitSha string) (string, error) {
|
||||||
|
cmdStr := "git show --no-color " + commitSha
|
||||||
|
diff, err := self.cmd.New(cmdStr).DontLog().RunWithOutput()
|
||||||
|
return diff, err
|
||||||
|
}
|
||||||
|
|
||||||
func (self *CommitCommands) GetCommitMessageFirstLine(sha string) (string, error) {
|
func (self *CommitCommands) GetCommitMessageFirstLine(sha string) (string, error) {
|
||||||
return self.GetCommitMessagesFirstLine([]string{sha})
|
return self.GetCommitMessagesFirstLine([]string{sha})
|
||||||
}
|
}
|
||||||
|
@ -229,28 +229,28 @@ type KeybindingBranchesConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KeybindingCommitsConfig struct {
|
type KeybindingCommitsConfig struct {
|
||||||
SquashDown string `yaml:"squashDown"`
|
SquashDown string `yaml:"squashDown"`
|
||||||
RenameCommit string `yaml:"renameCommit"`
|
RenameCommit string `yaml:"renameCommit"`
|
||||||
RenameCommitWithEditor string `yaml:"renameCommitWithEditor"`
|
RenameCommitWithEditor string `yaml:"renameCommitWithEditor"`
|
||||||
ViewResetOptions string `yaml:"viewResetOptions"`
|
ViewResetOptions string `yaml:"viewResetOptions"`
|
||||||
MarkCommitAsFixup string `yaml:"markCommitAsFixup"`
|
MarkCommitAsFixup string `yaml:"markCommitAsFixup"`
|
||||||
CreateFixupCommit string `yaml:"createFixupCommit"`
|
CreateFixupCommit string `yaml:"createFixupCommit"`
|
||||||
SquashAboveCommits string `yaml:"squashAboveCommits"`
|
SquashAboveCommits string `yaml:"squashAboveCommits"`
|
||||||
MoveDownCommit string `yaml:"moveDownCommit"`
|
MoveDownCommit string `yaml:"moveDownCommit"`
|
||||||
MoveUpCommit string `yaml:"moveUpCommit"`
|
MoveUpCommit string `yaml:"moveUpCommit"`
|
||||||
AmendToCommit string `yaml:"amendToCommit"`
|
AmendToCommit string `yaml:"amendToCommit"`
|
||||||
PickCommit string `yaml:"pickCommit"`
|
PickCommit string `yaml:"pickCommit"`
|
||||||
RevertCommit string `yaml:"revertCommit"`
|
RevertCommit string `yaml:"revertCommit"`
|
||||||
CherryPickCopy string `yaml:"cherryPickCopy"`
|
CherryPickCopy string `yaml:"cherryPickCopy"`
|
||||||
CherryPickCopyRange string `yaml:"cherryPickCopyRange"`
|
CherryPickCopyRange string `yaml:"cherryPickCopyRange"`
|
||||||
PasteCommits string `yaml:"pasteCommits"`
|
PasteCommits string `yaml:"pasteCommits"`
|
||||||
TagCommit string `yaml:"tagCommit"`
|
TagCommit string `yaml:"tagCommit"`
|
||||||
CheckoutCommit string `yaml:"checkoutCommit"`
|
CheckoutCommit string `yaml:"checkoutCommit"`
|
||||||
ResetCherryPick string `yaml:"resetCherryPick"`
|
ResetCherryPick string `yaml:"resetCherryPick"`
|
||||||
CopyCommitMessageToClipboard string `yaml:"copyCommitMessageToClipboard"`
|
CopyCommitAttributeToClipboard string `yaml:"copyCommitAttributeToClipboard"`
|
||||||
OpenLogMenu string `yaml:"openLogMenu"`
|
OpenLogMenu string `yaml:"openLogMenu"`
|
||||||
OpenInBrowser string `yaml:"openInBrowser"`
|
OpenInBrowser string `yaml:"openInBrowser"`
|
||||||
ViewBisectOptions string `yaml:"viewBisectOptions"`
|
ViewBisectOptions string `yaml:"viewBisectOptions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeybindingStashConfig struct {
|
type KeybindingStashConfig struct {
|
||||||
@ -496,28 +496,28 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
FetchRemote: "f",
|
FetchRemote: "f",
|
||||||
},
|
},
|
||||||
Commits: KeybindingCommitsConfig{
|
Commits: KeybindingCommitsConfig{
|
||||||
SquashDown: "s",
|
SquashDown: "s",
|
||||||
RenameCommit: "r",
|
RenameCommit: "r",
|
||||||
RenameCommitWithEditor: "R",
|
RenameCommitWithEditor: "R",
|
||||||
ViewResetOptions: "g",
|
ViewResetOptions: "g",
|
||||||
MarkCommitAsFixup: "f",
|
MarkCommitAsFixup: "f",
|
||||||
CreateFixupCommit: "F",
|
CreateFixupCommit: "F",
|
||||||
SquashAboveCommits: "S",
|
SquashAboveCommits: "S",
|
||||||
MoveDownCommit: "<c-j>",
|
MoveDownCommit: "<c-j>",
|
||||||
MoveUpCommit: "<c-k>",
|
MoveUpCommit: "<c-k>",
|
||||||
AmendToCommit: "A",
|
AmendToCommit: "A",
|
||||||
PickCommit: "p",
|
PickCommit: "p",
|
||||||
RevertCommit: "t",
|
RevertCommit: "t",
|
||||||
CherryPickCopy: "c",
|
CherryPickCopy: "c",
|
||||||
CherryPickCopyRange: "C",
|
CherryPickCopyRange: "C",
|
||||||
PasteCommits: "v",
|
PasteCommits: "v",
|
||||||
TagCommit: "T",
|
TagCommit: "T",
|
||||||
CheckoutCommit: "<space>",
|
CheckoutCommit: "<space>",
|
||||||
ResetCherryPick: "<c-R>",
|
ResetCherryPick: "<c-R>",
|
||||||
CopyCommitMessageToClipboard: "<c-y>",
|
CopyCommitAttributeToClipboard: "y",
|
||||||
OpenLogMenu: "<c-l>",
|
OpenLogMenu: "<c-l>",
|
||||||
OpenInBrowser: "o",
|
OpenInBrowser: "o",
|
||||||
ViewBisectOptions: "b",
|
ViewBisectOptions: "b",
|
||||||
},
|
},
|
||||||
Stash: KeybindingStashConfig{
|
Stash: KeybindingStashConfig{
|
||||||
PopStash: "g",
|
PopStash: "g",
|
||||||
|
@ -165,9 +165,10 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
|
|||||||
Description: self.c.Tr.LcTagCommit,
|
Description: self.c.Tr.LcTagCommit,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: opts.GetKey(opts.Config.Commits.CopyCommitMessageToClipboard),
|
Key: opts.GetKey(opts.Config.Commits.CopyCommitAttributeToClipboard),
|
||||||
Handler: self.checkSelected(self.copyCommitMessageToClipboard),
|
Handler: self.checkSelected(self.copyCommitAttribute),
|
||||||
Description: self.c.Tr.LcCopyCommitMessageToClipboard,
|
Description: self.c.Tr.LcCopyCommitAttributeToClipboard,
|
||||||
|
OpensMenu: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: opts.GetKey(opts.Config.Commits.OpenInBrowser),
|
Key: opts.GetKey(opts.Config.Commits.OpenInBrowser),
|
||||||
@ -599,6 +600,78 @@ func (self *LocalCommitsController) gotoBottom() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *LocalCommitsController) copyCommitAttribute(commit *models.Commit) error {
|
||||||
|
return self.c.Menu(types.CreateMenuOptions{
|
||||||
|
Title: self.c.Tr.Actions.CopyCommitAttributeToClipboard,
|
||||||
|
Items: []*types.MenuItem{
|
||||||
|
{
|
||||||
|
DisplayString: self.c.Tr.LcCommitSha,
|
||||||
|
OnPress: func() error {
|
||||||
|
return self.copyCommitSHAToClipboard(commit)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
DisplayString: self.c.Tr.LcCommitURL,
|
||||||
|
OnPress: func() error {
|
||||||
|
return self.copyCommitURLToClipboard(commit)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
DisplayString: self.c.Tr.LcCommitDiff,
|
||||||
|
OnPress: func() error {
|
||||||
|
return self.copyCommitDiffToClipboard(commit)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
DisplayString: self.c.Tr.LcCommitMessage,
|
||||||
|
OnPress: func() error {
|
||||||
|
return self.copyCommitMessageToClipboard(commit)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *LocalCommitsController) copyCommitSHAToClipboard(commit *models.Commit) error {
|
||||||
|
self.c.LogAction(self.c.Tr.Actions.CopyCommitSHAToClipboard)
|
||||||
|
if err := self.os.CopyToClipboard(commit.Sha); err != nil {
|
||||||
|
return self.c.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.c.Toast(self.c.Tr.CommitSHACopiedToClipboard)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *LocalCommitsController) copyCommitURLToClipboard(commit *models.Commit) error {
|
||||||
|
url, err := self.helpers.Host.GetCommitURL(commit.Sha)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
self.c.LogAction(self.c.Tr.Actions.CopyCommitURLToClipboard)
|
||||||
|
if err := self.os.CopyToClipboard(url); err != nil {
|
||||||
|
return self.c.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.c.Toast(self.c.Tr.CommitURLCopiedToClipboard)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *LocalCommitsController) copyCommitDiffToClipboard(commit *models.Commit) error {
|
||||||
|
diff, err := self.git.Commit.GetCommitDiff(commit.Sha)
|
||||||
|
if err != nil {
|
||||||
|
return self.c.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.c.LogAction(self.c.Tr.Actions.CopyCommitDiffToClipboard)
|
||||||
|
if err := self.os.CopyToClipboard(diff); err != nil {
|
||||||
|
return self.c.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.c.Toast(self.c.Tr.CommitDiffCopiedToClipboard)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (self *LocalCommitsController) copyCommitMessageToClipboard(commit *models.Commit) error {
|
func (self *LocalCommitsController) copyCommitMessageToClipboard(commit *models.Commit) error {
|
||||||
message, err := self.git.Commit.GetCommitMessage(commit.Sha)
|
message, err := self.git.Commit.GetCommitMessage(commit.Sha)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -611,7 +684,6 @@ func (self *LocalCommitsController) copyCommitMessageToClipboard(commit *models.
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.c.Toast(self.c.Tr.CommitMessageCopiedToClipboard)
|
self.c.Toast(self.c.Tr.CommitMessageCopiedToClipboard)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,8 +362,13 @@ type TranslationSet struct {
|
|||||||
LcOpenDiffingMenu string
|
LcOpenDiffingMenu string
|
||||||
LcOpenExtrasMenu string
|
LcOpenExtrasMenu string
|
||||||
LcShowingGitDiff string
|
LcShowingGitDiff string
|
||||||
|
LcCommitDiff string
|
||||||
LcCopyCommitShaToClipboard string
|
LcCopyCommitShaToClipboard string
|
||||||
|
LcCommitSha string
|
||||||
|
LcCommitURL string
|
||||||
LcCopyCommitMessageToClipboard string
|
LcCopyCommitMessageToClipboard string
|
||||||
|
LcCommitMessage string
|
||||||
|
LcCopyCommitAttributeToClipboard string
|
||||||
LcCopyBranchNameToClipboard string
|
LcCopyBranchNameToClipboard string
|
||||||
LcCopyFileNameToClipboard string
|
LcCopyFileNameToClipboard string
|
||||||
LcCopyCommitFileNameToClipboard string
|
LcCopyCommitFileNameToClipboard string
|
||||||
@ -415,6 +420,9 @@ type TranslationSet struct {
|
|||||||
ExtrasTitle string
|
ExtrasTitle string
|
||||||
PushingTagStatus string
|
PushingTagStatus string
|
||||||
PullRequestURLCopiedToClipboard string
|
PullRequestURLCopiedToClipboard string
|
||||||
|
CommitDiffCopiedToClipboard string
|
||||||
|
CommitSHACopiedToClipboard string
|
||||||
|
CommitURLCopiedToClipboard string
|
||||||
CommitMessageCopiedToClipboard string
|
CommitMessageCopiedToClipboard string
|
||||||
LcCopiedToClipboard string
|
LcCopiedToClipboard string
|
||||||
ErrCannotEditDirectory string
|
ErrCannotEditDirectory string
|
||||||
@ -505,6 +513,10 @@ type Actions struct {
|
|||||||
MoveCommitUp string
|
MoveCommitUp string
|
||||||
MoveCommitDown string
|
MoveCommitDown string
|
||||||
CopyCommitMessageToClipboard string
|
CopyCommitMessageToClipboard string
|
||||||
|
CopyCommitDiffToClipboard string
|
||||||
|
CopyCommitSHAToClipboard string
|
||||||
|
CopyCommitURLToClipboard string
|
||||||
|
CopyCommitAttributeToClipboard string
|
||||||
CustomCommand string
|
CustomCommand string
|
||||||
DiscardAllChangesInDirectory string
|
DiscardAllChangesInDirectory string
|
||||||
DiscardUnstagedChangesInDirectory string
|
DiscardUnstagedChangesInDirectory string
|
||||||
@ -941,8 +953,13 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
// the actual view is the extras view which I intend to give more tabs in future but for now we'll only mention the command log part
|
// the actual view is the extras view which I intend to give more tabs in future but for now we'll only mention the command log part
|
||||||
LcOpenExtrasMenu: "open command log menu",
|
LcOpenExtrasMenu: "open command log menu",
|
||||||
LcShowingGitDiff: "showing output for:",
|
LcShowingGitDiff: "showing output for:",
|
||||||
|
LcCommitDiff: "commit diff",
|
||||||
LcCopyCommitShaToClipboard: "copy commit SHA to clipboard",
|
LcCopyCommitShaToClipboard: "copy commit SHA to clipboard",
|
||||||
|
LcCommitSha: "commit SHA",
|
||||||
|
LcCommitURL: "commit URL",
|
||||||
LcCopyCommitMessageToClipboard: "copy commit message to clipboard",
|
LcCopyCommitMessageToClipboard: "copy commit message to clipboard",
|
||||||
|
LcCommitMessage: "commit message",
|
||||||
|
LcCopyCommitAttributeToClipboard: "copy commit attribute",
|
||||||
LcCopyBranchNameToClipboard: "copy branch name to clipboard",
|
LcCopyBranchNameToClipboard: "copy branch name to clipboard",
|
||||||
LcCopyFileNameToClipboard: "copy the file name to the clipboard",
|
LcCopyFileNameToClipboard: "copy the file name to the clipboard",
|
||||||
LcCopyCommitFileNameToClipboard: "copy the committed file name to the clipboard",
|
LcCopyCommitFileNameToClipboard: "copy the committed file name to the clipboard",
|
||||||
@ -993,6 +1010,9 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
ExtrasTitle: "Extras",
|
ExtrasTitle: "Extras",
|
||||||
PushingTagStatus: "pushing tag",
|
PushingTagStatus: "pushing tag",
|
||||||
PullRequestURLCopiedToClipboard: "Pull request URL copied to clipboard",
|
PullRequestURLCopiedToClipboard: "Pull request URL copied to clipboard",
|
||||||
|
CommitDiffCopiedToClipboard: "Commit diff copied to clipboard",
|
||||||
|
CommitSHACopiedToClipboard: "Commit SHA copied to clipboard",
|
||||||
|
CommitURLCopiedToClipboard: "Commit URL copied to clipboard",
|
||||||
CommitMessageCopiedToClipboard: "Commit message copied to clipboard",
|
CommitMessageCopiedToClipboard: "Commit message copied to clipboard",
|
||||||
LcCopiedToClipboard: "copied to clipboard",
|
LcCopiedToClipboard: "copied to clipboard",
|
||||||
ErrCannotEditDirectory: "Cannot edit directory: you can only edit individual files",
|
ErrCannotEditDirectory: "Cannot edit directory: you can only edit individual files",
|
||||||
@ -1064,6 +1084,10 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
CreateLightweightTag: "Create lightweight tag",
|
CreateLightweightTag: "Create lightweight tag",
|
||||||
CreateAnnotatedTag: "Create annotated tag",
|
CreateAnnotatedTag: "Create annotated tag",
|
||||||
CopyCommitMessageToClipboard: "Copy commit message to clipboard",
|
CopyCommitMessageToClipboard: "Copy commit message to clipboard",
|
||||||
|
CopyCommitDiffToClipboard: "Copy commit diff to clipboard",
|
||||||
|
CopyCommitSHAToClipboard: "Copy commit SHA to clipboard",
|
||||||
|
CopyCommitURLToClipboard: "Copy commit URL to clipboard",
|
||||||
|
CopyCommitAttributeToClipboard: "Copy to clipboard",
|
||||||
MoveCommitUp: "Move commit up",
|
MoveCommitUp: "Move commit up",
|
||||||
MoveCommitDown: "Move commit down",
|
MoveCommitDown: "Move commit down",
|
||||||
CustomCommand: "Custom command",
|
CustomCommand: "Custom command",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user