Cannot link package to an old repository if it's not in the top 30 #11616

Closed
opened 2025-11-02 09:42:34 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @Infinoid on GitHub (Sep 9, 2023).

Originally assigned to: @zjohnson87 on GitHub.

Description

While adding CICD to an older project, I pushed a docker image to gitea and attempted to link it to the git repo. On the package settings page for my new docker image, the git repo is not included in the projects list dropdown.

The dropdown list on the package settings page only shows the user's most recent 30 repositories. This dropdown box has no pagination controls, so it is not possible to link to older projects.

I did not understand what was happening, I thought maybe something was wrong with my git repo, until I turned SQL logging on. Here is the SQL query that GetUserRepositories ran:

2023/09/09 08:46:54 ...ls/repo/repo_list.go:731:GetUserRepositories() [I] [SQL] SELECT "id", "owner_id", "owner_name", "lower_name", "name", "description", "website", "original_service_type", "original_url", "default_branch", "num_watches", "num_stars", "num_forks", "num_issues", "num_closed_issues", "num_pulls", "num_closed_pulls", "num_milestones", "num_closed_milestones", "num_projects", "num_closed_projects", "num_action_runs", "num_closed_action_runs", "is_private", "is_empty", "is_archived", "is_mirror", "status", "is_fork", "fork_id", "is_template", "template_id", "size", "is_fsck_enabled", "close_issues_via_commit_in_any_branch", "topics", "trust_model", "avatar", "created_unix", "updated_unix", "archived_unix" FROM "repository" WHERE owner_id=$1 ORDER BY updated_unix DESC LIMIT 30 [1] - 697.708µs

The LIMIT 30 is why my older project was not listed.

Permalinks to the relevant code:

  1. PackageSettings endpoint
  2. GetUserRepositories function
  3. Package settings page template

The PackageSettings endpoint (1) calls GetUserRepositories to get the list of repositories, with no specific pagination options. The GetUserRepositories function (2) uses pagination by default, and limits the query to 30 results. These results are then shown on the package settings page (3), with no pagination controls, so it is not possible to see anything except for the first 30 results.

That's usually great; the most recent thing will show up first, and be easy to find. But it caused me confusion today while trying to add packages to an older project.

Maybe allow text entry of the repo name, or set ListAll=true in the ListOptions?

Gitea Version

1.20.4

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

docker image gitea/gitea:latest

Database

PostgreSQL

Originally created by @Infinoid on GitHub (Sep 9, 2023). Originally assigned to: @zjohnson87 on GitHub. ### Description While adding CICD to an older project, I pushed a docker image to gitea and attempted to link it to the git repo. On the package settings page for my new docker image, the git repo is not included in the projects list dropdown. The dropdown list on the package settings page only shows the user's most recent 30 repositories. This dropdown box has no pagination controls, so it is not possible to link to older projects. I did not understand what was happening, I thought maybe something was wrong with my git repo, until I turned SQL logging on. Here is the SQL query that `GetUserRepositories` ran: ``` 2023/09/09 08:46:54 ...ls/repo/repo_list.go:731:GetUserRepositories() [I] [SQL] SELECT "id", "owner_id", "owner_name", "lower_name", "name", "description", "website", "original_service_type", "original_url", "default_branch", "num_watches", "num_stars", "num_forks", "num_issues", "num_closed_issues", "num_pulls", "num_closed_pulls", "num_milestones", "num_closed_milestones", "num_projects", "num_closed_projects", "num_action_runs", "num_closed_action_runs", "is_private", "is_empty", "is_archived", "is_mirror", "status", "is_fork", "fork_id", "is_template", "template_id", "size", "is_fsck_enabled", "close_issues_via_commit_in_any_branch", "topics", "trust_model", "avatar", "created_unix", "updated_unix", "archived_unix" FROM "repository" WHERE owner_id=$1 ORDER BY updated_unix DESC LIMIT 30 [1] - 697.708µs ``` The `LIMIT 30` is why my older project was not listed. Permalinks to the relevant code: 1. [PackageSettings endpoint](https://github.com/go-gitea/gitea/blob/58abd4f06cb4f60777366122bc75a80fba074546/routers/web/user/package.go#L386-L390) 2. [GetUserRepositories function](https://github.com/go-gitea/gitea/blob/58abd4f06cb4f60777366122bc75a80fba074546/models/repo/repo_list.go#L746) 3. [Package settings page template](https://github.com/go-gitea/gitea/blob/58abd4f06cb4f60777366122bc75a80fba074546/templates/package/settings.tmpl#L27-L29) The PackageSettings endpoint (1) calls GetUserRepositories to get the list of repositories, with no specific pagination options. The GetUserRepositories function (2) uses pagination by default, and limits the query to 30 results. These results are then shown on the package settings page (3), with no pagination controls, so it is not possible to see anything except for the first 30 results. That's usually great; the most recent thing will show up first, and be easy to find. But it caused me confusion today while trying to add packages to an older project. Maybe allow text entry of the repo name, or set `ListAll=true` in the `ListOptions`? ### Gitea Version 1.20.4 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? docker image `gitea/gitea:latest` ### Database PostgreSQL
GiteaMirror added the topic/packagestype/bug labels 2025-11-02 09:42:34 -06:00
Author
Owner

@zjohnson87 commented on GitHub (Sep 10, 2023):

Could someone confirm the details of this fix? Specifically, do we want to set ListAll=true or do we want to add pagination options in the UI?

@techknowlogick

@zjohnson87 commented on GitHub (Sep 10, 2023): Could someone confirm the details of this fix? Specifically, do we want to set `ListAll=true` or do we want to add pagination options in the UI? @techknowlogick
Author
Owner

@Infinoid commented on GitHub (Sep 10, 2023):

Could someone confirm the details of this fix? Specifically, do we want to set ListAll=true or do we want to add pagination options in the UI?

Another possibility is to add a search option in the UI.

@Infinoid commented on GitHub (Sep 10, 2023): > Could someone confirm the details of this fix? Specifically, do we want to set `ListAll=true` or do we want to add pagination options in the UI? Another possibility is to add a search option in the UI.
Author
Owner

@KN4CK3R commented on GitHub (Sep 10, 2023):

Yes, best would be to display some recent repos if you click into the field. If it's not there you can start typing the name and the dropdown displays the matching results. Similar to what we have a main page on the right side.

@KN4CK3R commented on GitHub (Sep 10, 2023): Yes, best would be to display some recent repos if you click into the field. If it's not there you can start typing the name and the dropdown displays the matching results. Similar to what we have a main page on the right side.
Author
Owner

@zjohnson87 commented on GitHub (Sep 10, 2023):

How many results would we like to display? Is the default page size sufficient?

@zjohnson87 commented on GitHub (Sep 10, 2023): How many results would we like to display? Is the default page size sufficient?
Author
Owner

@Infinoid commented on GitHub (Sep 10, 2023):

Users can just keep typing until they see the one they want, so IMHO the page size/result count is probably fine as-is.

@Infinoid commented on GitHub (Sep 10, 2023): Users can just keep typing until they see the one they want, so IMHO the page size/result count is probably fine as-is.
Author
Owner

@zjohnson87 commented on GitHub (Sep 13, 2023):

What if I just pull down all the repos on the backend and filter them in the UI based on search text? I'm worried that making a query for repos every time a user stops typing isn't very performant (plus I'm not good at UI and can't figure out how to make a query based on user input).

@zjohnson87 commented on GitHub (Sep 13, 2023): What if I just pull down all the repos on the backend and filter them in the UI based on search text? I'm worried that making a query for repos every time a user stops typing isn't very performant (plus I'm not good at UI and can't figure out how to make a query based on user input).
Author
Owner

@KN4CK3R commented on GitHub (Oct 8, 2023):

Duplicate of #22749

@KN4CK3R commented on GitHub (Oct 8, 2023): Duplicate of #22749
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11616