diff options
author | Luka Markušić <luka.markusic@microblink.com> | 2022-07-30 08:10:29 +0200 |
---|---|---|
committer | Luka Markušić <luka.markusic@microblink.com> | 2022-07-30 08:10:29 +0200 |
commit | 1f482e585e6eccc4c56d7bbaf34cdaeee62ba8a5 (patch) | |
tree | 41ebaf0127badb87f0d34c5928c98cbb35d27015 /pkg | |
parent | 367b0d331836c90c015bf0c45f88612f3d94d08a (diff) |
Fix github linter errors
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/confirmation_panel.go | 38 | ||||
-rw-r--r-- | pkg/gui/context.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/upstream_helper.go | 8 | ||||
-rw-r--r-- | pkg/gui/presentation/reflog_commits.go | 31 | ||||
-rw-r--r-- | pkg/gui/types/common.go | 4 |
5 files changed, 49 insertions, 36 deletions
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index 5d8a13bb7..19f8745a8 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -123,29 +123,24 @@ func (gui *Gui) getConfirmationPanelWidth() int { } func (gui *Gui) prepareConfirmationPanel( - title, - prompt string, - hasLoader bool, - findSuggestionsFunc func(string) []*types.Suggestion, - editable bool, - mask bool, + opts types.ConfirmOpts, ) error { - gui.Views.Confirmation.HasLoader = hasLoader - if hasLoader { + gui.Views.Confirmation.HasLoader = opts.HasLoader + if opts.HasLoader { gui.g.StartTicking() } - gui.Views.Confirmation.Title = title + gui.Views.Confirmation.Title = opts.Title // 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.Mask = runeForMask(mask) + gui.Views.Confirmation.Mask = runeForMask(opts.Mask) - gui.findSuggestions = findSuggestionsFunc - if findSuggestionsFunc != nil { + gui.findSuggestions = opts.FindSuggestionsFunc + if opts.FindSuggestionsFunc != nil { suggestionsView := gui.Views.Suggestions suggestionsView.Wrap = false suggestionsView.FgColor = theme.GocuiDefaultTextColor - gui.setSuggestions(findSuggestionsFunc("")) + gui.setSuggestions(opts.FindSuggestionsFunc("")) suggestionsView.Visible = true 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() err := gui.prepareConfirmationPanel( - opts.Title, - opts.Prompt, - opts.HasLoader, - opts.FindSuggestionsFunc, - opts.Editable, - opts.Mask, - ) + types.ConfirmOpts{ + Title: opts.Title, + Prompt: opts.Prompt, + HasLoader: opts.HasLoader, + FindSuggestionsFunc: opts.FindSuggestionsFunc, + Editable: opts.Editable, + Mask: opts.Mask, + }) if err != nil { return err } diff --git a/pkg/gui/context.go b/pkg/gui/context.go index b83aa71c9..d2a99d84b 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -359,7 +359,7 @@ func (gui *Gui) getFocusLayout() func(g *gocui.Gui) error { newView := gui.g.CurrentView() // for now we don't consider losing focus to a popup panel as actually losing focus if newView != previousView && !gui.isPopupPanel(newView.Name()) { - if err := gui.onViewFocusLost(previousView, newView); err != nil { + if err := gui.onViewFocusLost(previousView); err != nil { 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 { return nil } diff --git a/pkg/gui/controllers/helpers/upstream_helper.go b/pkg/gui/controllers/helpers/upstream_helper.go index a3ece704e..a2d8e8ae2 100644 --- a/pkg/gui/controllers/helpers/upstream_helper.go +++ b/pkg/gui/controllers/helpers/upstream_helper.go @@ -49,7 +49,7 @@ func (self *UpstreamHelper) ParseUpstream(upstream string) (string, string, erro 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{ Title: self.c.Tr.EnterUpstream, InitialContent: initialContent, @@ -62,11 +62,11 @@ func (self *UpstreamHelper) PromptForUpstreamWithInitialContent(currentBranch *m suggestedRemote := self.GetSuggestedRemote() 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 { - return self.promptForUpstream(currentBranch, "", onConfirm) +func (self *UpstreamHelper) PromptForUpstreamWithoutInitialContent(_ *models.Branch, onConfirm func(string) error) error { + return self.promptForUpstream("", onConfirm) } func (self *UpstreamHelper) GetSuggestedRemote() string { diff --git a/pkg/gui/presentation/reflog_commits.go b/pkg/gui/presentation/reflog_commits.go index 15cd2cb74..5a49f0374 100644 --- a/pkg/gui/presentation/reflog_commits.go +++ b/pkg/gui/presentation/reflog_commits.go @@ -11,7 +11,7 @@ import ( ) 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 { displayFunc = getFullDescriptionDisplayStringsForReflogCommit } else { @@ -21,7 +21,13 @@ func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription return slices.Map(commits, func(commit *models.Commit) []string { diffed := commit.Sha == diffName 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 } -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 - if parseEmoji { + if attrs.parseEmoji { name = emoji.Sprint(name) } return []string{ - reflogShaColor(cherryPicked, diffed).Sprint(c.ShortSha()), - style.FgMagenta.Sprint(utils.UnixToDate(c.UnixTimestamp, timeFormat)), + reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortSha()), + style.FgMagenta.Sprint(utils.UnixToDate(c.UnixTimestamp, attrs.timeFormat)), 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 - if parseEmoji { + if attrs.parseEmoji { name = emoji.Sprint(name) } return []string{ - reflogShaColor(cherryPicked, diffed).Sprint(c.ShortSha()), + reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortSha()), theme.DefaultTextColor.Sprint(name), } } diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 9272317f9..72bba0b6c 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -96,6 +96,10 @@ type ConfirmOpts struct { HandleConfirm func() error HandleClose func() error HandlersManageFocus bool + HasLoader bool + FindSuggestionsFunc func(string) []*Suggestion + Editable bool + Mask bool } type PromptOpts struct { |