mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-17 01:42:45 +02:00
Merge pull request #2069 from mark2185/fix-github-linter
Fix github linter errors
This commit is contained in:
@ -123,29 +123,24 @@ func (gui *Gui) getConfirmationPanelWidth() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) prepareConfirmationPanel(
|
func (gui *Gui) prepareConfirmationPanel(
|
||||||
title,
|
opts types.ConfirmOpts,
|
||||||
prompt string,
|
|
||||||
hasLoader bool,
|
|
||||||
findSuggestionsFunc func(string) []*types.Suggestion,
|
|
||||||
editable bool,
|
|
||||||
mask bool,
|
|
||||||
) error {
|
) error {
|
||||||
gui.Views.Confirmation.HasLoader = hasLoader
|
gui.Views.Confirmation.HasLoader = opts.HasLoader
|
||||||
if hasLoader {
|
if opts.HasLoader {
|
||||||
gui.g.StartTicking()
|
gui.g.StartTicking()
|
||||||
}
|
}
|
||||||
gui.Views.Confirmation.Title = title
|
gui.Views.Confirmation.Title = opts.Title
|
||||||
// for now we do not support wrapping in our editor
|
// for now we do not support wrapping in our editor
|
||||||
gui.Views.Confirmation.Wrap = !editable
|
gui.Views.Confirmation.Wrap = !opts.Editable
|
||||||
gui.Views.Confirmation.FgColor = theme.GocuiDefaultTextColor
|
gui.Views.Confirmation.FgColor = theme.GocuiDefaultTextColor
|
||||||
gui.Views.Confirmation.Mask = runeForMask(mask)
|
gui.Views.Confirmation.Mask = runeForMask(opts.Mask)
|
||||||
|
|
||||||
gui.findSuggestions = findSuggestionsFunc
|
gui.findSuggestions = opts.FindSuggestionsFunc
|
||||||
if findSuggestionsFunc != nil {
|
if opts.FindSuggestionsFunc != nil {
|
||||||
suggestionsView := gui.Views.Suggestions
|
suggestionsView := gui.Views.Suggestions
|
||||||
suggestionsView.Wrap = false
|
suggestionsView.Wrap = false
|
||||||
suggestionsView.FgColor = theme.GocuiDefaultTextColor
|
suggestionsView.FgColor = theme.GocuiDefaultTextColor
|
||||||
gui.setSuggestions(findSuggestionsFunc(""))
|
gui.setSuggestions(opts.FindSuggestionsFunc(""))
|
||||||
suggestionsView.Visible = true
|
suggestionsView.Visible = true
|
||||||
suggestionsView.Title = fmt.Sprintf(gui.c.Tr.SuggestionsTitle, gui.c.UserConfig.Keybinding.Universal.TogglePanel)
|
suggestionsView.Title = fmt.Sprintf(gui.c.Tr.SuggestionsTitle, gui.c.UserConfig.Keybinding.Universal.TogglePanel)
|
||||||
}
|
}
|
||||||
@ -177,13 +172,14 @@ func (gui *Gui) createPopupPanel(opts types.CreatePopupPanelOpts) error {
|
|||||||
gui.clearConfirmationViewKeyBindings()
|
gui.clearConfirmationViewKeyBindings()
|
||||||
|
|
||||||
err := gui.prepareConfirmationPanel(
|
err := gui.prepareConfirmationPanel(
|
||||||
opts.Title,
|
types.ConfirmOpts{
|
||||||
opts.Prompt,
|
Title: opts.Title,
|
||||||
opts.HasLoader,
|
Prompt: opts.Prompt,
|
||||||
opts.FindSuggestionsFunc,
|
HasLoader: opts.HasLoader,
|
||||||
opts.Editable,
|
FindSuggestionsFunc: opts.FindSuggestionsFunc,
|
||||||
opts.Mask,
|
Editable: opts.Editable,
|
||||||
)
|
Mask: opts.Mask,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ func (gui *Gui) getFocusLayout() func(g *gocui.Gui) error {
|
|||||||
newView := gui.g.CurrentView()
|
newView := gui.g.CurrentView()
|
||||||
// for now we don't consider losing focus to a popup panel as actually losing focus
|
// for now we don't consider losing focus to a popup panel as actually losing focus
|
||||||
if newView != previousView && !gui.isPopupPanel(newView.Name()) {
|
if newView != previousView && !gui.isPopupPanel(newView.Name()) {
|
||||||
if err := gui.onViewFocusLost(previousView, newView); err != nil {
|
if err := gui.onViewFocusLost(previousView); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ func (gui *Gui) getFocusLayout() func(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) onViewFocusLost(oldView *gocui.View, newView *gocui.View) error {
|
func (gui *Gui) onViewFocusLost(oldView *gocui.View) error {
|
||||||
if oldView == nil {
|
if oldView == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func (self *UpstreamHelper) ParseUpstream(upstream string) (string, string, erro
|
|||||||
return upstreamRemote, upstreamBranch, nil
|
return upstreamRemote, upstreamBranch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *UpstreamHelper) promptForUpstream(currentBranch *models.Branch, initialContent string, onConfirm func(string) error) error {
|
func (self *UpstreamHelper) promptForUpstream(initialContent string, onConfirm func(string) error) error {
|
||||||
return self.c.Prompt(types.PromptOpts{
|
return self.c.Prompt(types.PromptOpts{
|
||||||
Title: self.c.Tr.EnterUpstream,
|
Title: self.c.Tr.EnterUpstream,
|
||||||
InitialContent: initialContent,
|
InitialContent: initialContent,
|
||||||
@ -62,11 +62,11 @@ func (self *UpstreamHelper) PromptForUpstreamWithInitialContent(currentBranch *m
|
|||||||
suggestedRemote := self.GetSuggestedRemote()
|
suggestedRemote := self.GetSuggestedRemote()
|
||||||
initialContent := suggestedRemote + " " + currentBranch.Name
|
initialContent := suggestedRemote + " " + currentBranch.Name
|
||||||
|
|
||||||
return self.promptForUpstream(currentBranch, initialContent, onConfirm)
|
return self.promptForUpstream(initialContent, onConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *UpstreamHelper) PromptForUpstreamWithoutInitialContent(currentBranch *models.Branch, onConfirm func(string) error) error {
|
func (self *UpstreamHelper) PromptForUpstreamWithoutInitialContent(_ *models.Branch, onConfirm func(string) error) error {
|
||||||
return self.promptForUpstream(currentBranch, "", onConfirm)
|
return self.promptForUpstream("", onConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *UpstreamHelper) GetSuggestedRemote() string {
|
func (self *UpstreamHelper) GetSuggestedRemote() string {
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitShaSet *set.Set[string], diffName string, timeFormat string, parseEmoji bool) [][]string {
|
func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitShaSet *set.Set[string], diffName string, timeFormat string, parseEmoji bool) [][]string {
|
||||||
var displayFunc func(*models.Commit, string, bool, bool, bool) []string
|
var displayFunc func(*models.Commit, reflogCommitDisplayAttributes) []string
|
||||||
if fullDescription {
|
if fullDescription {
|
||||||
displayFunc = getFullDescriptionDisplayStringsForReflogCommit
|
displayFunc = getFullDescriptionDisplayStringsForReflogCommit
|
||||||
} else {
|
} else {
|
||||||
@ -21,7 +21,13 @@ func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription
|
|||||||
return slices.Map(commits, func(commit *models.Commit) []string {
|
return slices.Map(commits, func(commit *models.Commit) []string {
|
||||||
diffed := commit.Sha == diffName
|
diffed := commit.Sha == diffName
|
||||||
cherryPicked := cherryPickedCommitShaSet.Includes(commit.Sha)
|
cherryPicked := cherryPickedCommitShaSet.Includes(commit.Sha)
|
||||||
return displayFunc(commit, timeFormat, cherryPicked, diffed, parseEmoji)
|
return displayFunc(commit,
|
||||||
|
reflogCommitDisplayAttributes{
|
||||||
|
cherryPicked: cherryPicked,
|
||||||
|
diffed: diffed,
|
||||||
|
parseEmoji: parseEmoji,
|
||||||
|
timeFormat: timeFormat,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,27 +44,34 @@ func reflogShaColor(cherryPicked, diffed bool) style.TextStyle {
|
|||||||
return shaColor
|
return shaColor
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFullDescriptionDisplayStringsForReflogCommit(c *models.Commit, timeFormat string, cherryPicked, diffed, parseEmoji bool) []string {
|
type reflogCommitDisplayAttributes struct {
|
||||||
|
cherryPicked bool
|
||||||
|
diffed bool
|
||||||
|
parseEmoji bool
|
||||||
|
timeFormat string
|
||||||
|
}
|
||||||
|
|
||||||
|
func getFullDescriptionDisplayStringsForReflogCommit(c *models.Commit, attrs reflogCommitDisplayAttributes) []string {
|
||||||
name := c.Name
|
name := c.Name
|
||||||
if parseEmoji {
|
if attrs.parseEmoji {
|
||||||
name = emoji.Sprint(name)
|
name = emoji.Sprint(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return []string{
|
return []string{
|
||||||
reflogShaColor(cherryPicked, diffed).Sprint(c.ShortSha()),
|
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortSha()),
|
||||||
style.FgMagenta.Sprint(utils.UnixToDate(c.UnixTimestamp, timeFormat)),
|
style.FgMagenta.Sprint(utils.UnixToDate(c.UnixTimestamp, attrs.timeFormat)),
|
||||||
theme.DefaultTextColor.Sprint(name),
|
theme.DefaultTextColor.Sprint(name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDisplayStringsForReflogCommit(c *models.Commit, timeFormat string, cherryPicked, diffed, parseEmoji bool) []string {
|
func getDisplayStringsForReflogCommit(c *models.Commit, attrs reflogCommitDisplayAttributes) []string {
|
||||||
name := c.Name
|
name := c.Name
|
||||||
if parseEmoji {
|
if attrs.parseEmoji {
|
||||||
name = emoji.Sprint(name)
|
name = emoji.Sprint(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return []string{
|
return []string{
|
||||||
reflogShaColor(cherryPicked, diffed).Sprint(c.ShortSha()),
|
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortSha()),
|
||||||
theme.DefaultTextColor.Sprint(name),
|
theme.DefaultTextColor.Sprint(name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,10 @@ type ConfirmOpts struct {
|
|||||||
HandleConfirm func() error
|
HandleConfirm func() error
|
||||||
HandleClose func() error
|
HandleClose func() error
|
||||||
HandlersManageFocus bool
|
HandlersManageFocus bool
|
||||||
|
HasLoader bool
|
||||||
|
FindSuggestionsFunc func(string) []*Suggestion
|
||||||
|
Editable bool
|
||||||
|
Mask bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type PromptOpts struct {
|
type PromptOpts struct {
|
||||||
|
Reference in New Issue
Block a user