From 018556c286f2a26bfd2def0769d82b87c5b6ba3e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 Aug 2025 14:31:13 +0000 Subject: [PATCH] Fix all exhaustive switch case issues and some godot/nolintlint issues Co-authored-by: caarlos0 <245435+caarlos0@users.noreply.github.com> --- cmd/soft/browse/browse.go | 4 ++++ git/patch.go | 2 +- pkg/config/config.go | 2 +- pkg/lfs/basic_transfer.go | 10 +++++----- pkg/lfs/client.go | 8 ++++---- pkg/ssh/ui.go | 4 ++++ pkg/ui/pages/repo/files.go | 14 ++++++++++++++ pkg/ui/pages/repo/log.go | 12 +++++++++++- pkg/ui/pages/repo/stash.go | 6 ++++++ pkg/ui/pages/selection/selection.go | 6 ++++++ pkg/web/git.go | 2 +- pkg/webhook/repository.go | 2 ++ 12 files changed, 59 insertions(+), 13 deletions(-) diff --git a/cmd/soft/browse/browse.go b/cmd/soft/browse/browse.go index ecb3d5302d44aebee5147d5540477bd79d4ba6c6..24bbbbd30e39df29f3c5a8a3da61244ace10f20e 100644 --- a/cmd/soft/browse/browse.go +++ b/cmd/soft/browse/browse.go @@ -109,6 +109,8 @@ func (m model) ShortHelp() []key.Binding { m.common.KeyMap.Quit, m.common.KeyMap.Help, } + case startState: + return m.model.ShortHelp() default: return m.model.ShortHelp() } @@ -127,6 +129,8 @@ func (m model) FullHelp() [][]key.Binding { m.common.KeyMap.Help, }, } + case startState: + return m.model.FullHelp() default: return m.model.FullHelp() } diff --git a/git/patch.go b/git/patch.go index 11d9aa017f6a23da15d78354c21c3b09e87f33fc..a856d795e9eb1347f8c00418a96eab2240d39af6 100644 --- a/git/patch.go +++ b/git/patch.go @@ -136,7 +136,7 @@ func (f *DiffFile) Files() (from *DiffFileChange, to *DiffFileChange) { return } -// FileStats +// FileStats. type FileStats []*DiffFile // String returns a string representation of file stats. diff --git a/pkg/config/config.go b/pkg/config/config.go index b492b7058d1a160381590881d8fc122b394722ca..0d7832db7d2f2287bec965f498bfa1927acb39cc 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -307,7 +307,7 @@ func DefaultDataPath() string { } // ConfigPath returns the path to the config file. -func (c *Config) ConfigPath() string { //nolint:revive +func (c *Config) ConfigPath() string { // If we have a custom config location set, then use that. if path := os.Getenv("SOFT_SERVE_CONFIG_LOCATION"); exist(path) { return path diff --git a/pkg/lfs/basic_transfer.go b/pkg/lfs/basic_transfer.go index 8bcf812252533c8da381a83cb0b78c4894ad4f41..73df38635a1cbd212595799ba7192e528752a929 100644 --- a/pkg/lfs/basic_transfer.go +++ b/pkg/lfs/basic_transfer.go @@ -12,17 +12,17 @@ import ( "github.com/charmbracelet/log/v2" ) -// BasicTransferAdapter implements the "basic" adapter +// BasicTransferAdapter implements the "basic" adapter. type BasicTransferAdapter struct { client *http.Client } -// Name returns the name of the adapter +// Name returns the name of the adapter. func (a *BasicTransferAdapter) Name() string { return "basic" } -// Download reads the download location and downloads the data +// Download reads the download location and downloads the data. func (a *BasicTransferAdapter) Download(ctx context.Context, _ Pointer, l *Link) (io.ReadCloser, error) { resp, err := a.performRequest(ctx, "GET", l, nil, nil) if err != nil { @@ -31,7 +31,7 @@ func (a *BasicTransferAdapter) Download(ctx context.Context, _ Pointer, l *Link) return resp.Body, nil } -// Upload sends the content to the LFS server +// Upload sends the content to the LFS server. func (a *BasicTransferAdapter) Upload(ctx context.Context, p Pointer, r io.Reader, l *Link) error { res, err := a.performRequest(ctx, "PUT", l, r, func(req *http.Request) { if len(req.Header.Get("Content-Type")) == 0 { @@ -50,7 +50,7 @@ func (a *BasicTransferAdapter) Upload(ctx context.Context, p Pointer, r io.Reade return res.Body.Close() } -// Verify calls the verify handler on the LFS server +// Verify calls the verify handler on the LFS server. func (a *BasicTransferAdapter) Verify(ctx context.Context, p Pointer, l *Link) error { logger := log.FromContext(ctx).WithPrefix("lfs") b, err := json.Marshal(p) diff --git a/pkg/lfs/client.go b/pkg/lfs/client.go index 70bfbc0f42296669b027429a97ce3e089389bda7..556b0d17dfcf99ef6edf3d1d277f21299d6e8b27 100644 --- a/pkg/lfs/client.go +++ b/pkg/lfs/client.go @@ -6,16 +6,16 @@ import ( ) const ( - // SchemeHTTP represents the HTTP protocol scheme + // SchemeHTTP represents the HTTP protocol scheme. SchemeHTTP = "http" - // SchemeHTTPS represents the HTTPS protocol scheme + // SchemeHTTPS represents the HTTPS protocol scheme. SchemeHTTPS = "https" ) -// DownloadCallback gets called for every requested LFS object to process its content +// DownloadCallback gets called for every requested LFS object to process its content. type DownloadCallback func(p Pointer, content io.ReadCloser, objectError error) error -// UploadCallback gets called for every requested LFS object to provide its content +// UploadCallback gets called for every requested LFS object to provide its content. type UploadCallback func(p Pointer, objectError error) (io.ReadCloser, error) // Client is a Git LFS client to communicate with a LFS source API. diff --git a/pkg/ssh/ui.go b/pkg/ssh/ui.go index e08cc89a31f110b56a1f9b28da3b95ea518eac46..766dcee8d626e733edabcde55461feddb4b43531 100644 --- a/pkg/ssh/ui.go +++ b/pkg/ssh/ui.go @@ -91,6 +91,8 @@ func (ui *UI) ShortHelp() []key.Binding { b = append(b, ui.common.KeyMap.Back) case readyState: b = append(b, ui.pages[ui.activePage].ShortHelp()...) + case loadingState: + // No key bindings while loading } if !ui.IsFiltering() { b = append(b, ui.common.KeyMap.Quit) @@ -107,6 +109,8 @@ func (ui *UI) FullHelp() [][]key.Binding { b = append(b, []key.Binding{ui.common.KeyMap.Back}) case readyState: b = append(b, ui.pages[ui.activePage].FullHelp()...) + case loadingState: + // No key bindings while loading } h := []key.Binding{ ui.common.KeyMap.Help, diff --git a/pkg/ui/pages/repo/files.go b/pkg/ui/pages/repo/files.go index 6e8c4affdc51fad43d065d9e3f24f8664723fb14..5f0196ef96ffb15f0de5915528bbae0d9c9ea59f 100644 --- a/pkg/ui/pages/repo/files.go +++ b/pkg/ui/pages/repo/files.go @@ -268,6 +268,8 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch f.activeView { case filesViewFiles, filesViewContent: cmds = append(cmds, f.deselectItemCmd()) + case filesViewLoading: + // Do nothing while loading } case tea.KeyPressMsg: switch f.activeView { @@ -303,6 +305,8 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) { f.code.UseGlamour = !f.code.UseGlamour cmds = append(cmds, f.code.SetContent(f.currentContent.content, f.currentContent.ext)) } + case filesViewLoading: + // No key handling while loading } case tea.WindowSizeMsg: f.SetSize(msg.Width, msg.Height) @@ -319,6 +323,8 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) { cmds = append(cmds, cmd) } } + case filesViewLoading: + // Do nothing while loading } case EmptyRepoMsg: f.ref = nil @@ -350,6 +356,12 @@ func (f *Files) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if cmd != nil { cmds = append(cmds, cmd) } + case filesViewLoading: + m, cmd := f.spinner.Update(msg) + f.spinner = m + if cmd != nil { + cmds = append(cmds, cmd) + } } return f, tea.Batch(cmds...) } @@ -389,6 +401,8 @@ func (f *Files) StatusBarInfo() string { return fmt.Sprintf("# %d/%d", f.selector.Index()+1, len(f.selector.VisibleItems())) case filesViewContent: return common.ScrollPercent(f.code.ScrollPosition()) + case filesViewLoading: + return "Loading..." default: return "" } diff --git a/pkg/ui/pages/repo/log.go b/pkg/ui/pages/repo/log.go index e38399f492842c0e2624b6ff0a5f061022d448e5..a5992b6ce74c557a18093a213e500ecfcc82a189 100644 --- a/pkg/ui/pages/repo/log.go +++ b/pkg/ui/pages/repo/log.go @@ -88,8 +88,10 @@ func (l *Log) Path() string { switch l.activeView { case logViewCommits: return "" - default: + case logViewLoading, logViewDiff: return "diff" // XXX: this is a place holder and doesn't mean anything + default: + return "diff" } } @@ -126,6 +128,8 @@ func (l *Log) ShortHelp() []key.Binding { l.common.KeyMap.GotoTop, l.common.KeyMap.GotoBottom, } + case logViewLoading: + return []key.Binding{} default: return []key.Binding{} } @@ -178,6 +182,8 @@ func (l *Log) FullHelp() [][]key.Binding { l.common.KeyMap.GotoBottom, }, }...) + case logViewLoading: + // No key bindings while loading } return b } @@ -264,6 +270,8 @@ func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } } + case logViewLoading: + // No key handling while loading } case GoBackMsg: l.goBack() @@ -342,6 +350,8 @@ func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if cmd != nil { cmds = append(cmds, cmd) } + case logViewLoading, logViewCommits: + // No additional viewport updates needed } return l, tea.Batch(cmds...) } diff --git a/pkg/ui/pages/repo/stash.go b/pkg/ui/pages/repo/stash.go index 10b0bbf2b63b2bbbcfbbbf2f18f39acf7d4699b9..4591723af1aa1ee81c80c747473b2843cf1c1ddc 100644 --- a/pkg/ui/pages/repo/stash.go +++ b/pkg/ui/pages/repo/stash.go @@ -129,6 +129,8 @@ func (s *Stash) StatusBarInfo() string { return fmt.Sprintf("p. %d/%d", s.list.Page()+1, totalPages) case stashStatePatch: return common.ScrollPercent(s.code.ScrollPosition()) + case stashStateLoading: + return "Loading..." default: return "" } @@ -184,6 +186,8 @@ func (s *Stash) Update(msg tea.Msg) (tea.Model, tea.Cmd) { cmds = append(cmds, copyCmd(patch.Patch(), "Stash patch copied to clipboard")) } } + case stashStateLoading: + // No key handling while loading } case StashListMsg: s.state = stashStateList @@ -230,6 +234,8 @@ func (s *Stash) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if cmd != nil { cmds = append(cmds, cmd) } + case stashStateLoading: + // No updates while loading } return s, tea.Batch(cmds...) } diff --git a/pkg/ui/pages/selection/selection.go b/pkg/ui/pages/selection/selection.go index fdabb15137244b36c27df359f4e9acb9cf8d31b7..c8e74ae73b0adb21c7b91f695b0f04b5e118bf50 100644 --- a/pkg/ui/pages/selection/selection.go +++ b/pkg/ui/pages/selection/selection.go @@ -176,6 +176,8 @@ func (s *Selection) FullHelp() [][]key.Binding { k.CancelWhileFiltering, k.AcceptWhileFiltering, }) + case lastPane: + // lastPane is not a real pane, used for bounds checking } return b } @@ -279,6 +281,8 @@ func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if cmd != nil { cmds = append(cmds, cmd) } + case lastPane: + // lastPane is not a real pane, no updates needed } return s, tea.Batch(cmds...) } @@ -306,6 +310,8 @@ func (s *Selection) View() string { s.readme.View(), readmeStatus, )) + case lastPane: + // lastPane is not a real pane, no view } if s.activePane != selectorPane || s.FilterState() != list.Filtering { tabs := s.common.Styles.Tabs.Render(s.tabs.View()) diff --git a/pkg/web/git.go b/pkg/web/git.go index 6ed16ee625955095a3ed65f4ccbdddfe88ab17ce..99ce36dd0141001dfc0c416a9dee17ef0aca9f10 100644 --- a/pkg/web/git.go +++ b/pkg/web/git.go @@ -461,7 +461,7 @@ type flushResponseWriter struct { } func (f *flushResponseWriter) ReadFrom(r io.Reader) (int64, error) { - flusher := http.NewResponseController(f.ResponseWriter) //nolint: bodyclose + flusher := http.NewResponseController(f.ResponseWriter) var n int64 p := make([]byte, 1024) diff --git a/pkg/webhook/repository.go b/pkg/webhook/repository.go index 30d1033a16b0df4a3386fdc4e9a1dd4db0f59167..904738e9a31ae20c810bb0add03d0bcaa5b837c6 100644 --- a/pkg/webhook/repository.go +++ b/pkg/webhook/repository.go @@ -37,6 +37,8 @@ func NewRepositoryEvent(ctx context.Context, user proto.User, repo proto.Reposit switch action { case RepositoryEventActionVisibilityChange: event = EventRepositoryVisibilityChange + case RepositoryEventActionDelete, RepositoryEventActionRename, RepositoryEventActionDefaultBranchChange: + event = EventRepository default: event = EventRepository }