[PR #2371] [CLOSED] Refactor searchRepositoryByName function and remove another redundant function #16369

Closed
opened 2025-11-02 12:09:01 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/2371
Author: @Morlinest
Created: 8/23/2017
Status: Closed

Base: masterHead: fix/missing-collaborative-repositories


📝 Commits (10+)

  • a50f7a8 Add more repo search tests
  • 50867df Add and fix /api/repo/search integration tests
  • 2d8b046 Add owner to access table for organization repositories
  • 27f037d Fix repo search tests
  • 4fcbded Always test returned repos length
  • 8cb7ce2 Add test with lower pagesize limit (test more pages)
  • dae998e Fix/rewrite searchRepositoryByName function
  • 7c9323d Remove authorization decisions making
  • 9da9e96 Fix search of starred repositories
  • 14f73a3 Simplify code

📊 Changes

14 files changed (+507 additions, -192 deletions)

View changed files

📝 integrations/api_repo_test.go (+107 -1)
📝 models/fixtures/access.yml (+24 -0)
📝 models/fixtures/org_user.yml (+8 -0)
📝 models/fixtures/repository.yml (+97 -0)
📝 models/fixtures/team.yml (+9 -0)
📝 models/fixtures/team_repo.yml (+12 -0)
📝 models/fixtures/team_user.yml (+6 -0)
📝 models/fixtures/user.yml (+47 -0)
📝 models/org_test.go (+1 -1)
📝 models/repo_list.go (+81 -110)
📝 models/repo_list_test.go (+68 -8)
📝 routers/api/v1/repo/repo.go (+16 -22)
📝 routers/home.go (+21 -40)
📝 routers/user/profile.go (+10 -10)

📄 Description

Should fix some bugs (eg. #2365), should replace #2367 changes to models/repo_list.go.

I've rewrote function used by api/repo/search to give correct results. I commented everything, so hopefully it should be clear. Should include users repositories and also collaborative repositories (tested by user tests, finaly I see everything). Now returns repositories of related organizations based on public/private search (known/unknown Searcher or Searcher.IsAdmin) Also includes some protective logic.

My rewrite is based on assumption:

  1. Always searching for opts.OwnerID repositories
  2. opts.Searcher is here to identify who is searching and what rights this user has to search opts.OwnerID repositories.

Please check it.

PS: Integration tests would be usefull, but right now I can't do any tests for gitea.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/2371 **Author:** [@Morlinest](https://github.com/Morlinest) **Created:** 8/23/2017 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/missing-collaborative-repositories` --- ### 📝 Commits (10+) - [`a50f7a8`](https://github.com/go-gitea/gitea/commit/a50f7a8cbf9b38270afe8b080033204eac178ef9) Add more repo search tests - [`50867df`](https://github.com/go-gitea/gitea/commit/50867dfe7f3e97fbffe19dafae7b43f40c48422b) Add and fix /api/repo/search integration tests - [`2d8b046`](https://github.com/go-gitea/gitea/commit/2d8b046ea0f7383a15a545d207d714ce04d69d14) Add owner to access table for organization repositories - [`27f037d`](https://github.com/go-gitea/gitea/commit/27f037d321826dbe4c85592975e10ecddee3a3f5) Fix repo search tests - [`4fcbded`](https://github.com/go-gitea/gitea/commit/4fcbded80930fe562f33482b2e1d368cb8ac854f) Always test returned repos length - [`8cb7ce2`](https://github.com/go-gitea/gitea/commit/8cb7ce2afb733bf83a76d38ab1719547247fc677) Add test with lower pagesize limit (test more pages) - [`dae998e`](https://github.com/go-gitea/gitea/commit/dae998e50b9781db60d640eda40ae475c0333268) Fix/rewrite searchRepositoryByName function - [`7c9323d`](https://github.com/go-gitea/gitea/commit/7c9323dc1fbefe316dff5673da22e80080306fa5) Remove authorization decisions making - [`9da9e96`](https://github.com/go-gitea/gitea/commit/9da9e960a641bfacb6781e871882b4c731644fe1) Fix search of starred repositories - [`14f73a3`](https://github.com/go-gitea/gitea/commit/14f73a3795f759ed2d81bbd99290a590c72903d5) Simplify code ### 📊 Changes **14 files changed** (+507 additions, -192 deletions) <details> <summary>View changed files</summary> 📝 `integrations/api_repo_test.go` (+107 -1) 📝 `models/fixtures/access.yml` (+24 -0) 📝 `models/fixtures/org_user.yml` (+8 -0) 📝 `models/fixtures/repository.yml` (+97 -0) 📝 `models/fixtures/team.yml` (+9 -0) 📝 `models/fixtures/team_repo.yml` (+12 -0) 📝 `models/fixtures/team_user.yml` (+6 -0) 📝 `models/fixtures/user.yml` (+47 -0) 📝 `models/org_test.go` (+1 -1) 📝 `models/repo_list.go` (+81 -110) 📝 `models/repo_list_test.go` (+68 -8) 📝 `routers/api/v1/repo/repo.go` (+16 -22) 📝 `routers/home.go` (+21 -40) 📝 `routers/user/profile.go` (+10 -10) </details> ### 📄 Description Should fix some bugs (eg. #2365), should replace #2367 changes to `models/repo_list.go`. I've rewrote function used by `api/repo/search` to give correct results. I commented everything, so hopefully it should be clear. Should include users repositories and also collaborative repositories (tested by user tests, finaly I see everything). Now returns repositories of related organizations based on public/private search (known/unknown `Searcher` or `Searcher.IsAdmin`) Also includes some protective logic. My rewrite is based on assumption: 1. Always searching for `opts.OwnerID` repositories 2. `opts.Searcher` is here to identify who is searching and what rights this user has to search `opts.OwnerID` repositories. Please check it. PS: Integration tests would be usefull, but right now I can't do any tests for gitea. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:09:01 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#16369