Add Codeberg support and improve multi-forge integration - #109
Conversation
Integrate Codeberg as a third supported Git forge alongside GitHub and GitLab. Add CODEBERG_TOKEN environment variable, implement Codeberg provider with API endpoints for repos, commits, issues, PRs, releases, discussions and wiki. Add /api/cb-proxy/ handler to avoid CORS issues. Update search functionality to include Codeberg repositories with language and topic filtering. Improve commit anonymization to handle repos with non-main
|
Warning Review limit reached
Next review available in: 24 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (10)
📝 WalkthroughWalkthroughAdds end-to-end Codeberg support across configuration, provider APIs, Git routing, search/trending, repository browsing, anonymous interactions, UI controls, and documentation. It also makes commit anonymization use the remote default branch when available. ChangesCodeberg provider foundation
Backend routing and APIs
Global web UI
Repository browser
Documentation
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47615bc442
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 13
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
web/index.html (2)
3222-3267: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winSame Codeberg color inconsistency as the push modal.
Line 3225 uses
color:#20883d`` for thecbcode snippet, inconsistent with `#2185D0` used elsewhere for Codeberg. See consolidated comment.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/index.html` around lines 3222 - 3267, Update the Codeberg provider snippet in the Base URL description to use the established `#2185D0` color, replacing the inconsistent `#20883d` value while leaving the GitHub and GitLab styling unchanged.
1721-1741: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCodeberg accent color doesn't match the color used elsewhere for Codeberg.
for Codeberg is styled with
color:#20883d`` here, but the Codeberg badge icon, rate-limit ring, and forge badges elsewhere in this file consistently use#2185D0. See consolidated comment for all affected sites.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/index.html` around lines 1721 - 1741, Update the inline color styling for the Codeberg endpoint code in the surrounding GitHub/GitLab/Codeberg block to use the established Codeberg accent color `#2185D0`, matching the badge icon, rate-limit ring, and other forge badges in this file.
🧹 Nitpick comments (1)
web/repo.html (1)
3131-3178: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueConsider a page cap on the pagination loops.
while (true)relies solely on the upstreamLinkheader; a misbehaving/proxied response that keeps advertisingrel="next"with non-empty data will loop indefinitely. Apage <= 20guard is cheap insurance.Also applies to: 3242-3286
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/repo.html` around lines 3131 - 3178, Update the pagination loops in loadBranches and the corresponding loop at the additionally affected branch-loading section to add a page <= 20 guard alongside the existing response and Link-header checks. Preserve current pagination behavior within the cap while preventing further requests once the page limit is reached.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/git/receive.go`:
- Around line 275-283: Update AnonymizeCommits to resolve the remote default
branch reliably when refs/remotes/origin/HEAD is unavailable: inspect the
clone’s local HEAD or origin refs/symbolic HEAD to identify the actual default
branch, and only then use origin/main as a final fallback. Ensure the resolved
base reference populates baseCommits so existing default-branch commits are not
rewritten.
In `@internal/http/handlers.go`:
- Around line 478-482: Update both UploadPack handlers to allow anonymous
fetches when the provider token environment variable is unset: remove the
unconditional 500 response and set the upstream Authorization header only when a
non-empty token exists. Preserve authenticated requests by retaining the header
when the token is available.
- Around line 2861-2896: The unrestricted Codeberg proxy must restrict
credentialed forwarding and add request throttling. In CodebergProxyHandler,
validate the extracted path against an allow-list such as api/v1/... and
.../raw/branch/... before constructing target, and only apply CODEBERG_TOKEN for
allowed paths; reject disallowed paths. In internal/http/router.go lines
328-329, wrap the route with the existing limiter pattern used by
prCheckLimiter() on /api/pr/:hash/status.
- Around line 3195-3207: Reduce the GitLab language backfill in the search flow
around the `langs`/`getGitLabPrimaryLanguage` goroutines: only perform lookups
for results whose `item.Language` is empty and cap backfilling to a small
leading subset of results, while preserving existing language values and the
current backfill behavior for trending results.
In `@internal/provider/codeberg/codeberg.go`:
- Line 582: Update the error message returned at the Codeberg provider’s
discussion handling path to begin with a lowercase character, preserving the
existing message meaning so it satisfies Go error-string style checks.
In `@LEGAL.md`:
- Line 225: Update the visible attribution text in LEGAL.md from
“github/linguist” to “GitHub Linguist” while preserving the existing repository
URL and surrounding Spanish text.
In `@README.md`:
- Line 14: Update the README description to replace “free & open source” with
“free and open-source,” preserving the rest of the wording unchanged.
In `@web/index.html`:
- Around line 4231-4244: Update the Codeberg rate-limit block in
updateRateLimit() to pass the established Codeberg blue `#2185D0` to
updateRateLimitRing instead of green, keeping the ring consistent with the
static icon and other Codeberg elements.
- Around line 3014-3035: Update the renderer containing forgeIconHtml,
languageBadgeHtml, and item.innerHTML to escape repo.owner and repo.repo before
interpolating them into the HTML template. Reuse the existing HTML-escaping
helper or add one consistent with the other affected renderers, while leaving
the URL encodeURIComponent handling and visual markup unchanged.
- Around line 2594-2606: Update loadLanguageColors and its use in init so the
third-party request cannot block initial rendering: load cached language colors
from localStorage when fresh, fetch with an AbortController timeout when needed,
and persist successful results with a TTL. Start rendering via showTagPage,
performSearch, or loadTrending without awaiting the color load, then apply the
loaded colors and refresh badges once the request completes.
- Around line 4010-4024: Escape repo.description before inserting it into
item.innerHTML, while preserving the existing 120-character truncation and
empty-description behavior. Update the description rendering in the item
construction flow and reuse the established HTML-escaping helper from the
consolidated changes if available; ensure malicious markup is rendered as text
rather than interpreted.
In `@web/repo.html`:
- Around line 4397-4402: Update the Codeberg branch in the content-fetching flow
around cbFetch so item.path is passed with slashes preserved, matching
_fetchDirItems; avoid encoding the entire nested path, and only encode
individual path segments if required by the URL construction.
- Line 1948: Update currentBranch() and all Codeberg raw-link construction
paths, including the direct image/raw Markdown links, so an unavailable
rv.branch produces the provider’s /raw/ URL without a HEAD ref; otherwise use
the resolved branch value. Ensure loadRepoInfo() can still supply the default
branch before constructing URLs when available.
---
Outside diff comments:
In `@web/index.html`:
- Around line 3222-3267: Update the Codeberg provider snippet in the Base URL
description to use the established `#2185D0` color, replacing the inconsistent
`#20883d` value while leaving the GitHub and GitLab styling unchanged.
- Around line 1721-1741: Update the inline color styling for the Codeberg
endpoint code in the surrounding GitHub/GitLab/Codeberg block to use the
established Codeberg accent color `#2185D0`, matching the badge icon, rate-limit
ring, and other forge badges in this file.
---
Nitpick comments:
In `@web/repo.html`:
- Around line 3131-3178: Update the pagination loops in loadBranches and the
corresponding loop at the additionally affected branch-loading section to add a
page <= 20 guard alongside the existing response and Link-header checks.
Preserve current pagination behavior within the cap while preventing further
requests once the page limit is reached.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b8181e60-0a2f-46b0-995a-1f5662ce4118
⛔ Files ignored due to path filters (1)
web/assets/sponsors/openbin.livrasand.com.pngis excluded by!**/*.png
📒 Files selected for processing (10)
.env.exampleLEGAL.mdREADME.mdinternal/config/config.gointernal/git/receive.gointernal/http/handlers.gointernal/http/router.gointernal/provider/codeberg/codeberg.goweb/index.htmlweb/repo.html
Allow anonymous git-upload-pack requests when tokens are not configured. Fix commit anonymization to use local HEAD branch instead of assuming origin/main. Add path validation to Codeberg proxy to restrict access to API and raw endpoints only. Fix GitLab search URL encoding and limit language backfill requests. Resolve Codeberg issue label names to IDs when creating anonymous issues. Add comprehensive tests for anonymous upload-pack and commit anonymization with non-main branches.
Integrate Codeberg as a third supported Git forge alongside GitHub and GitLab. Add CODEBERG_TOKEN environment variable, implement Codeberg provider with API endpoints for repos, commits, issues, PRs, releases, discussions and wiki. Add /api/cb-proxy/ handler to avoid CORS issues. Update search functionality to include Codeberg repositories with language and topic filtering. Improve commit anonymization to handle repos with non-main
Summary by CodeRabbit
New Features
Documentation
Bug Fixes