1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

rename displayString to label for menu items

This commit is contained in:
Jesse Duffield
2022-05-08 14:23:32 +10:00
parent 125e948d82
commit 6f8063217d
23 changed files with 126 additions and 122 deletions

View File

@ -101,35 +101,35 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e
Title: self.c.Tr.Actions.CopyCommitAttributeToClipboard,
Items: []*types.MenuItem{
{
DisplayString: self.c.Tr.LcCommitSha,
Label: self.c.Tr.LcCommitSha,
OnPress: func() error {
return self.copyCommitSHAToClipboard(commit)
},
Key: 's',
},
{
DisplayString: self.c.Tr.LcCommitURL,
Label: self.c.Tr.LcCommitURL,
OnPress: func() error {
return self.copyCommitURLToClipboard(commit)
},
Key: 'u',
},
{
DisplayString: self.c.Tr.LcCommitDiff,
Label: self.c.Tr.LcCommitDiff,
OnPress: func() error {
return self.copyCommitDiffToClipboard(commit)
},
Key: 'd',
},
{
DisplayString: self.c.Tr.LcCommitMessage,
Label: self.c.Tr.LcCommitMessage,
OnPress: func() error {
return self.copyCommitMessageToClipboard(commit)
},
Key: 'm',
},
{
DisplayString: self.c.Tr.LcCommitAuthor,
Label: self.c.Tr.LcCommitAuthor,
OnPress: func() error {
return self.copyAuthorToClipboard(commit)
},

View File

@ -67,7 +67,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
menuItems := []*types.MenuItem{
{
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.NewTerm()),
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.NewTerm()),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectMark)
if err := self.git.Bisect.Mark(commit.Sha, info.NewTerm()); err != nil {
@ -79,7 +79,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 'b',
},
{
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()),
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectMark)
if err := self.git.Bisect.Mark(commit.Sha, info.OldTerm()); err != nil {
@ -91,7 +91,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 'g',
},
{
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()),
Label: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectSkip)
if err := self.git.Bisect.Skip(commit.Sha); err != nil {
@ -103,7 +103,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 's',
},
{
DisplayString: self.c.Tr.Bisect.ResetOption,
Label: self.c.Tr.Bisect.ResetOption,
OnPress: func() error {
return self.helpers.Bisect.Reset()
},
@ -122,7 +122,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
Title: self.c.Tr.Bisect.BisectMenuTitle,
Items: []*types.MenuItem{
{
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.NewTerm()),
Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.NewTerm()),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.StartBisect)
if err := self.git.Bisect.Start(); err != nil {
@ -138,7 +138,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
Key: 'b',
},
{
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()),
Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()),
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.StartBisect)
if err := self.git.Bisect.Start(); err != nil {

View File

@ -111,7 +111,7 @@ func (self *BranchesController) setUpstream(selectedBranch *models.Branch) error
Title: self.c.Tr.Actions.SetUnsetUpstream,
Items: []*types.MenuItem{
{
DisplayStrings: []string{self.c.Tr.LcUnsetUpstream},
LabelColumns: []string{self.c.Tr.LcUnsetUpstream},
OnPress: func() error {
if err := self.git.Branch.UnsetUpstream(selectedBranch.Name); err != nil {
return self.c.Error(err)
@ -130,7 +130,7 @@ func (self *BranchesController) setUpstream(selectedBranch *models.Branch) error
Key: 'u',
},
{
DisplayStrings: []string{self.c.Tr.LcSetUpstream},
LabelColumns: []string{self.c.Tr.LcSetUpstream},
OnPress: func() error {
return self.helpers.Upstream.PromptForUpstreamWithoutInitialContent(selectedBranch, func(upstream string) error {
upstreamRemote, upstreamBranch, err := self.helpers.Upstream.ParseUpstream(upstream)
@ -417,20 +417,20 @@ func (self *BranchesController) newBranch(selectedBranch *models.Branch) error {
func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Branch, checkedOutBranch *models.Branch) error {
menuItems := make([]*types.MenuItem, 0, 4)
fromToDisplayStrings := func(from string, to string) []string {
fromToLabelColumns := func(from string, to string) []string {
return []string{fmt.Sprintf("%s → %s", from, to)}
}
menuItemsForBranch := func(branch *models.Branch) []*types.MenuItem {
return []*types.MenuItem{
{
DisplayStrings: fromToDisplayStrings(branch.Name, self.c.Tr.LcDefaultBranch),
LabelColumns: fromToLabelColumns(branch.Name, self.c.Tr.LcDefaultBranch),
OnPress: func() error {
return self.createPullRequest(branch.Name, "")
},
},
{
DisplayStrings: fromToDisplayStrings(branch.Name, self.c.Tr.LcSelectBranch),
LabelColumns: fromToLabelColumns(branch.Name, self.c.Tr.LcSelectBranch),
OnPress: func() error {
return self.c.Prompt(types.PromptOpts{
Title: branch.Name + " →",
@ -447,7 +447,7 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra
if selectedBranch != checkedOutBranch {
menuItems = append(menuItems,
&types.MenuItem{
DisplayStrings: fromToDisplayStrings(checkedOutBranch.Name, selectedBranch.Name),
LabelColumns: fromToLabelColumns(checkedOutBranch.Name, selectedBranch.Name),
OnPress: func() error {
return self.createPullRequest(checkedOutBranch.Name, selectedBranch.Name)
},

View File

@ -500,19 +500,19 @@ func (self *FilesController) handleStatusFilterPressed() error {
Title: self.c.Tr.FilteringMenuTitle,
Items: []*types.MenuItem{
{
DisplayString: self.c.Tr.FilterStagedFiles,
Label: self.c.Tr.FilterStagedFiles,
OnPress: func() error {
return self.setStatusFiltering(filetree.DisplayStaged)
},
},
{
DisplayString: self.c.Tr.FilterUnstagedFiles,
Label: self.c.Tr.FilterUnstagedFiles,
OnPress: func() error {
return self.setStatusFiltering(filetree.DisplayUnstaged)
},
},
{
DisplayString: self.c.Tr.ResetCommitFilterState,
Label: self.c.Tr.ResetCommitFilterState,
OnPress: func() error {
return self.setStatusFiltering(filetree.DisplayAll)
},
@ -557,14 +557,14 @@ func (self *FilesController) createStashMenu() error {
Title: self.c.Tr.LcStashOptions,
Items: []*types.MenuItem{
{
DisplayString: self.c.Tr.LcStashAllChanges,
Label: self.c.Tr.LcStashAllChanges,
OnPress: func() error {
return self.handleStashSave(self.git.Stash.Save, self.c.Tr.Actions.StashAllChanges, self.c.Tr.NoFilesToStash)
},
Key: 'a',
},
{
DisplayString: self.c.Tr.LcStashAllChangesKeepIndex,
Label: self.c.Tr.LcStashAllChangesKeepIndex,
OnPress: func() error {
// if there are no staged files it behaves the same as Stash.Save
return self.handleStashSave(self.git.Stash.StashAndKeepIndex, self.c.Tr.Actions.StashAllChangesKeepIndex, self.c.Tr.NoFilesToStash)
@ -572,7 +572,7 @@ func (self *FilesController) createStashMenu() error {
Key: 'i',
},
{
DisplayString: self.c.Tr.LcStashStagedChanges,
Label: self.c.Tr.LcStashStagedChanges,
OnPress: func() error {
// there must be something in staging otherwise the current implementation mucks the stash up
if !self.helpers.WorkingTree.AnyStagedFiles() {
@ -583,7 +583,7 @@ func (self *FilesController) createStashMenu() error {
Key: 's',
},
{
DisplayString: self.c.Tr.LcStashUnstagedChanges,
Label: self.c.Tr.LcStashUnstagedChanges,
OnPress: func() error {
if self.helpers.WorkingTree.AnyStagedFiles() {
return self.handleStashSave(self.git.Stash.StashUnstagedChanges, self.c.Tr.Actions.StashUnstagedChanges, self.c.Tr.NoFilesToStash)

View File

@ -43,7 +43,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
if node.File == nil {
menuItems = []*types.MenuItem{
{
DisplayString: self.c.Tr.LcDiscardAllChanges,
Label: self.c.Tr.LcDiscardAllChanges,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.DiscardAllChangesInDirectory)
if err := self.git.WorkingTree.DiscardAllDirChanges(node); err != nil {
@ -57,7 +57,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
if node.GetHasStagedChanges() && node.GetHasUnstagedChanges() {
menuItems = append(menuItems, &types.MenuItem{
DisplayString: self.c.Tr.LcDiscardUnstagedChanges,
Label: self.c.Tr.LcDiscardUnstagedChanges,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.DiscardUnstagedChangesInDirectory)
if err := self.git.WorkingTree.DiscardUnstagedDirChanges(node); err != nil {
@ -78,7 +78,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
menuItems = []*types.MenuItem{
{
DisplayString: self.c.Tr.LcSubmoduleStashAndReset,
Label: self.c.Tr.LcSubmoduleStashAndReset,
OnPress: func() error {
return self.ResetSubmodule(submodule)
},
@ -87,7 +87,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
} else {
menuItems = []*types.MenuItem{
{
DisplayString: self.c.Tr.LcDiscardAllChanges,
Label: self.c.Tr.LcDiscardAllChanges,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.DiscardAllChangesInFile)
if err := self.git.WorkingTree.DiscardAllFileChanges(file); err != nil {
@ -101,7 +101,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
if file.HasStagedChanges && file.HasUnstagedChanges {
menuItems = append(menuItems, &types.MenuItem{
DisplayString: self.c.Tr.LcDiscardUnstagedChanges,
Label: self.c.Tr.LcDiscardUnstagedChanges,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.DiscardAllUnstagedChangesInFile)
if err := self.git.WorkingTree.DiscardUnstagedFileChanges(file); err != nil {

View File

@ -64,30 +64,30 @@ func (self *GitFlowController) handleCreateGitFlowMenu(branch *models.Branch) er
Items: []*types.MenuItem{
{
// not localising here because it's one to one with the actual git flow commands
DisplayString: fmt.Sprintf("finish branch '%s'", branch.Name),
Label: fmt.Sprintf("finish branch '%s'", branch.Name),
OnPress: func() error {
return self.gitFlowFinishBranch(branch.Name)
},
},
{
DisplayString: "start feature",
OnPress: startHandler("feature"),
Key: 'f',
Label: "start feature",
OnPress: startHandler("feature"),
Key: 'f',
},
{
DisplayString: "start hotfix",
OnPress: startHandler("hotfix"),
Key: 'h',
Label: "start hotfix",
OnPress: startHandler("hotfix"),
Key: 'h',
},
{
DisplayString: "start bugfix",
OnPress: startHandler("bugfix"),
Key: 'b',
Label: "start bugfix",
OnPress: startHandler("bugfix"),
Key: 'b',
},
{
DisplayString: "start release",
OnPress: startHandler("release"),
Key: 'r',
Label: "start release",
OnPress: startHandler("release"),
Key: 'r',
},
},
})

View File

@ -64,7 +64,7 @@ func (self *MergeAndRebaseHelper) CreateRebaseOptionsMenu() error {
menuItems := slices.Map(options, func(row optionAndKey) *types.MenuItem {
return &types.MenuItem{
DisplayString: row.option,
Label: row.option,
OnPress: func() error {
return self.genericMergeCommand(row.option)
},

View File

@ -146,7 +146,7 @@ func (self *RefsHelper) CreateGitResetMenu(ref string) error {
menuItems := slices.Map(strengths, func(row strengthWithKey) *types.MenuItem {
return &types.MenuItem{
DisplayStrings: []string{
LabelColumns: []string{
fmt.Sprintf("%s reset", row.strength),
style.FgRed.Sprintf("reset --%s %s", row.strength, ref),
},

View File

@ -26,13 +26,13 @@ func (self *TagsHelper) CreateTagMenu(commitSha string, onCreate func()) error {
Title: self.c.Tr.TagMenuTitle,
Items: []*types.MenuItem{
{
DisplayString: self.c.Tr.LcLightweightTag,
Label: self.c.Tr.LcLightweightTag,
OnPress: func() error {
return self.handleCreateLightweightTag(commitSha, onCreate)
},
},
{
DisplayString: self.c.Tr.LcAnnotatedTag,
Label: self.c.Tr.LcAnnotatedTag,
OnPress: func() error {
return self.handleCreateAnnotatedTag(commitSha, onCreate)
},

View File

@ -470,7 +470,7 @@ func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.C
}
menuItems[i] = &types.MenuItem{
DisplayString: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message),
Label: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message),
OnPress: func() error {
parentNumber := i + 1
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
@ -570,7 +570,7 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
Title: self.c.Tr.LogMenuTitle,
Items: []*types.MenuItem{
{
DisplayString: self.c.Tr.ToggleShowGitGraphAll,
Label: self.c.Tr.ToggleShowGitGraphAll,
OnPress: func() error {
self.context().SetShowWholeGitGraph(!self.context().GetShowWholeGitGraph())
@ -586,8 +586,8 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
},
},
{
DisplayString: self.c.Tr.ShowGitGraph,
OpensMenu: true,
Label: self.c.Tr.ShowGitGraph,
OpensMenu: true,
OnPress: func() error {
onPress := func(value string) func() error {
return func() error {
@ -599,24 +599,24 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
Title: self.c.Tr.LogMenuTitle,
Items: []*types.MenuItem{
{
DisplayString: "always",
OnPress: onPress("always"),
Label: "always",
OnPress: onPress("always"),
},
{
DisplayString: "never",
OnPress: onPress("never"),
Label: "never",
OnPress: onPress("never"),
},
{
DisplayString: "when maximised",
OnPress: onPress("when-maximised"),
Label: "when maximised",
OnPress: onPress("when-maximised"),
},
},
})
},
},
{
DisplayString: self.c.Tr.SortCommits,
OpensMenu: true,
Label: self.c.Tr.SortCommits,
OpensMenu: true,
OnPress: func() error {
onPress := func(value string) func() error {
return func() error {
@ -636,16 +636,16 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
Title: self.c.Tr.LogMenuTitle,
Items: []*types.MenuItem{
{
DisplayString: "topological (topo-order)",
OnPress: onPress("topo-order"),
Label: "topological (topo-order)",
OnPress: onPress("topo-order"),
},
{
DisplayString: "date-order",
OnPress: onPress("date-order"),
Label: "date-order",
OnPress: onPress("date-order"),
},
{
DisplayString: "author-date-order",
OnPress: onPress("author-date-order"),
Label: "author-date-order",
OnPress: onPress("author-date-order"),
},
},
})

View File

@ -146,7 +146,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
Title: self.c.Tr.LcBulkSubmoduleOptions,
Items: []*types.MenuItem{
{
DisplayStrings: []string{self.c.Tr.LcBulkInitSubmodules, style.FgGreen.Sprint(self.git.Submodule.BulkInitCmdObj().ToString())},
LabelColumns: []string{self.c.Tr.LcBulkInitSubmodules, style.FgGreen.Sprint(self.git.Submodule.BulkInitCmdObj().ToString())},
OnPress: func() error {
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
self.c.LogAction(self.c.Tr.Actions.BulkInitialiseSubmodules)
@ -161,7 +161,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
Key: 'i',
},
{
DisplayStrings: []string{self.c.Tr.LcBulkUpdateSubmodules, style.FgYellow.Sprint(self.git.Submodule.BulkUpdateCmdObj().ToString())},
LabelColumns: []string{self.c.Tr.LcBulkUpdateSubmodules, style.FgYellow.Sprint(self.git.Submodule.BulkUpdateCmdObj().ToString())},
OnPress: func() error {
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
self.c.LogAction(self.c.Tr.Actions.BulkUpdateSubmodules)
@ -175,7 +175,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
Key: 'u',
},
{
DisplayStrings: []string{self.c.Tr.LcBulkDeinitSubmodules, style.FgRed.Sprint(self.git.Submodule.BulkDeinitCmdObj().ToString())},
LabelColumns: []string{self.c.Tr.LcBulkDeinitSubmodules, style.FgRed.Sprint(self.git.Submodule.BulkDeinitCmdObj().ToString())},
OnPress: func() error {
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
self.c.LogAction(self.c.Tr.Actions.BulkDeinitialiseSubmodules)

View File

@ -19,7 +19,7 @@ func (self *FilesController) createResetMenu() error {
menuItems := []*types.MenuItem{
{
DisplayStrings: []string{
LabelColumns: []string{
self.c.Tr.LcDiscardAllChangesToAllFiles,
red.Sprint(nukeStr),
},
@ -35,7 +35,7 @@ func (self *FilesController) createResetMenu() error {
Tooltip: self.c.Tr.NukeDescription,
},
{
DisplayStrings: []string{
LabelColumns: []string{
self.c.Tr.LcDiscardAnyUnstagedChanges,
red.Sprint("git checkout -- ."),
},
@ -50,7 +50,7 @@ func (self *FilesController) createResetMenu() error {
Key: 'u',
},
{
DisplayStrings: []string{
LabelColumns: []string{
self.c.Tr.LcDiscardUntrackedFiles,
red.Sprint("git clean -fd"),
},
@ -65,7 +65,7 @@ func (self *FilesController) createResetMenu() error {
Key: 'c',
},
{
DisplayStrings: []string{
LabelColumns: []string{
self.c.Tr.LcSoftReset,
red.Sprint("git reset --soft HEAD"),
},
@ -80,7 +80,7 @@ func (self *FilesController) createResetMenu() error {
Key: 's',
},
{
DisplayStrings: []string{
LabelColumns: []string{
"mixed reset",
red.Sprint("git reset --mixed HEAD"),
},
@ -95,7 +95,7 @@ func (self *FilesController) createResetMenu() error {
Key: 'm',
},
{
DisplayStrings: []string{
LabelColumns: []string{
self.c.Tr.LcHardReset,
red.Sprint("git reset --hard HEAD"),
},