mirror of https://github.com/go-gitea/gitea.git
Description This PR adds a branch_count field to the repository API response. Currently, clients have to fetch all branches via /branches just to determine the total number of branches. This addition brings Gitea closer to parity with GitLab's API and improves efficiency for UI/CLI clients that need this metric. Linked Issue Fixes #35351 Changes API Structs: Added BranchCount field to Repository struct in modules/structs/repo.go. Database Logic: Implemented CountBranches in models/git/branch.go using XORM for efficient counting. Service Layer: Updated the ToRepo conversion logic in services/convert/repository.go to populate the new field during API serialisation. Tests: Added a new unit test TestCountBranches in models/git/branch_test.go to verify counts (including handling of deleted branches). Screenshots <img width="196" height="121" alt="Screenshot 2026-02-24 at 21 41 07" src="https://github.com/user-attachments/assets/cd023e92-f338-448b-9e49-0a5d54cc96c2" /> Testing Manually verified the output using curl against a local Gitea instance. Verified that adding a branch increments the count and deleting a branch (soft-delete) decrements it. Ran backend linting: make lint-backend (Passed). Ran specific unit test: go test -v -tags "sqlite sqlite_unlock_notify" ./models/git -run TestCountBranches (Passed). Co-authored-by: silverwind <me@silverwind.io> |
||
|---|---|---|
| .. | ||
| actions | ||
| activitypub | ||
| analyze | ||
| assetfs | ||
| auth | ||
| avatar | ||
| badge | ||
| base | ||
| cache | ||
| cachegroup | ||
| charset | ||
| commitstatus | ||
| container | ||
| csv | ||
| dump | ||
| emoji | ||
| eventsource | ||
| fileicon | ||
| generate | ||
| git | ||
| gitrepo | ||
| glob | ||
| globallock | ||
| graceful | ||
| gtprof | ||
| hcaptcha | ||
| highlight | ||
| hostmatcher | ||
| htmlutil | ||
| httpcache | ||
| httplib | ||
| indexer | ||
| issue/template | ||
| json | ||
| label | ||
| lfs | ||
| lfstransfer | ||
| log | ||
| markup | ||
| mcaptcha | ||
| metrics | ||
| migration | ||
| nosql | ||
| optional | ||
| options | ||
| packages | ||
| paginator | ||
| pprof | ||
| private | ||
| process | ||
| proxy | ||
| proxyprotocol | ||
| public | ||
| queue | ||
| recaptcha | ||
| references | ||
| regexplru | ||
| repository | ||
| reqctx | ||
| secret | ||
| session | ||
| setting | ||
| sitemap | ||
| ssh | ||
| storage | ||
| structs | ||
| svg | ||
| system | ||
| tailmsg | ||
| tempdir | ||
| templates | ||
| test | ||
| testlogger | ||
| timeutil | ||
| translation | ||
| turnstile | ||
| typesniffer | ||
| updatechecker | ||
| uri | ||
| user | ||
| util | ||
| validation | ||
| web | ||
| webhook | ||
| zstd | ||