Skip to content

Conversation

@bimakw
Copy link

Summary

This PR refactors the SearchIssues function in routers/api/v1/repo/issue.go by extracting common logic into reusable helper functions:

  • parseIssueIsClosed(): Parses the "state" query parameter and returns the corresponding isClosed option
  • parseIssueIsPull(): Parses the "type" query parameter and returns the corresponding isPull option
  • buildSearchIssuesRepoIDs(): Builds the list of repository IDs for issue search based on query parameters

Benefits:

  • Improved code readability
  • Smaller, more focused functions
  • Easier to test individual components
  • Potential for reuse in other handlers

Changes:

  • Extracted 3 helper functions from the ~292 line SearchIssues function
  • No functional changes - behavior remains the same
  • Proper error handling preserved

Test plan

  • Verify existing API tests pass
  • Manual testing of /repos/issues/search endpoint

Ref: #35015

Split the SearchIssues function into smaller, more maintainable pieces: - parseIssueIsClosed: parses "state" query parameter - parseIssueIsPull: parses "type" query parameter - buildSearchIssuesRepoIDs: builds repository IDs list for search This improves code readability and makes the logic easier to test and reuse. Ref: go-gitea#35015
@GiteaBotGiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 14, 2025
@github-actionsgithub-actionsbot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Dec 14, 2025
Replace fmt.Errorf with errors.New for better performance as suggested by perfsprint linter.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2This PR needs two approvals by maintainers to be considered for merging.modifies/apiThis PR adds API routes or modifies themmodifies/goPull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@bimakw@GiteaBot