Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: extract helper functions from SearchIssues#36158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
bimakw wants to merge1 commit intogo-gitea:main
base:main
Choose a base branch
Loading
frombimakw:refactor/split-search-issues

Conversation

@bimakw
Copy link

Summary

This PR refactors theSearchIssues function inrouters/api/v1/repo/issue.go by extracting common logic into reusable helper functions:

  • parseIssueIsClosed(): Parses the "state" query parameter and returns the correspondingisClosed option
  • parseIssueIsPull(): Parses the "type" query parameter and returns the correspondingisPull 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 lineSearchIssues 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

@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelDec 14, 2025
@github-actionsgithub-actionsbot added modifies/apiThis PR adds API routes or modifies them modifies/goPull requests that update Go code labelsDec 14, 2025
Extract parseIssueIsClosed, parseIssueIsPull, and buildSearchIssuesRepoIDshelper functions to improve code readability and maintainability.- parseIssueIsClosed: parses "state" query parameter- parseIssueIsPull: parses "type" query parameter- buildSearchIssuesRepoIDs: builds repository IDs for issue searchAlso consolidate error handling conditions using || operator.
@bimakwbimakwforce-pushed therefactor/split-search-issues branch frome04b0bd to8909fceCompareDecember 18, 2025 10:11
@bimakw
Copy link
Author

Thanks@lunny for the review! Updated to use|| operator to consolidate the error handling conditions.

@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelsDec 18, 2025
iferr!=nil {
repoIDs,allPublic,err:=buildSearchIssuesRepoIDs(ctx)
iferr!=nil {
ifuser_model.IsErrUserNotExist(err)||organization.IsErrTeamNotExist(err)||err.Error()=="owner organisation is required for filtering on team" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

err.Error() == "owner organisation is required for filtering on team"

please don't do this, it is an abuse to Golang error system and is very fragile.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@wxiaoguangwxiaoguangwxiaoguang left review comments

@lunnylunnylunny approved these changes

Assignees

No one assigned

Labels

lgtm/need 1This PR needs approval from one additional maintainer to be merged.modifies/apiThis PR adds API routes or modifies themmodifies/goPull requests that update Go code

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@bimakw@lunny@wxiaoguang@GiteaBot

[8]ページ先頭

©2009-2025 Movatter.jp