Skip to content

Add Codeberg support and improve multi-forge integration - #109

Merged
livrasand merged 3 commits into
mainfrom
Add-Codeberg-support-and-improve-multi-forge-integration
Jul 27, 2026
Merged

Add Codeberg support and improve multi-forge integration#109
livrasand merged 3 commits into
mainfrom
Add-Codeberg-support-and-improve-multi-forge-integration

Conversation

@livrasand

@livrasand livrasand commented Jul 27, 2026

Copy link
Copy Markdown
Owner

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

    • Added Codeberg support for anonymous repository browsing, cloning, pushing, issues, pull requests, comments, search, and trending repositories.
    • Added Codeberg repository pages with branches, commits, files, releases, wiki content, language badges, and provider-aware links.
    • Added interactive rate-limit status displays for GitHub, GitLab, and Codeberg.
    • Added optional Codeberg personal access token configuration.
  • Documentation

    • Updated project descriptions, hosting availability, feature listings, legal contact information, and asset attributions.
  • Bug Fixes

    • Improved commit processing by selecting the repository’s default remote branch when available.

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
@livrasand livrasand self-assigned this Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@livrasand, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 154f20b2-c06c-442d-83bf-95ebc1ce2307

📥 Commits

Reviewing files that changed from the base of the PR and between 47615bc and 3b11c91.

⛔ Files ignored due to path filters (3)
  • web/assets/screenshots/home.png is excluded by !**/*.png
  • web/assets/screenshots/repo.png is excluded by !**/*.png
  • web/assets/screenshots/search.png is excluded by !**/*.png
📒 Files selected for processing (10)
  • LEGAL.md
  • README.md
  • internal/git/git_test.go
  • internal/git/receive.go
  • internal/http/handlers.go
  • internal/http/handlers_upload_test.go
  • internal/http/router.go
  • internal/provider/codeberg/codeberg.go
  • web/index.html
  • web/repo.html
📝 Walkthrough

Walkthrough

Adds 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.

Changes

Codeberg provider foundation

Layer / File(s) Summary
Provider configuration and operations
internal/config/config.go, internal/provider/codeberg/codeberg.go, .env.example
Adds CODEBERG_TOKEN loading and implements Codeberg repository, fork, pull request, policy, issue, comment, reference, and status operations.

Backend routing and APIs

Layer / File(s) Summary
Codeberg Git and API routing
internal/http/router.go, internal/http/handlers.go, internal/git/receive.go
Adds Codeberg Git routes, authenticated upload-pack requests, proxying, pull request tracking and rollback, search/trending aggregation, language metadata, and default-branch commit detection.

Global web UI

Layer / File(s) Summary
Provider controls and presentation
web/index.html
Adds Codeberg command tabs, provider selectors, forge and language badges, rate-limit controls and modal behavior, and updated project metadata.

Repository browser

Layer / File(s) Summary
Codeberg repository views
web/repo.html
Adds Codeberg-aware repository loading, branches, packages, wiki, issues, pull requests, releases, commits, files, links, cloning, and branch-based markdown rendering.

Documentation

Layer / File(s) Summary
Project documentation and presentation
README.md, LEGAL.md
Updates platform descriptions, hosting badges, feature descriptions, contact information, and attribution details.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related issues

  • livrasand/gitGost#32 — Directly covers the Codeberg provider, backend, routing, API, and UI support implemented here.

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: gitgost-anonymous, gitgost-anonymous

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Codeberg support and broader multi-forge integration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Add-Codeberg-support-and-improve-multi-forge-integration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread internal/http/handlers.go Outdated
Comment thread internal/http/handlers.go Outdated
Comment thread internal/provider/codeberg/codeberg.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Same Codeberg color inconsistency as the push modal.

Line 3225 uses color:#20883d`` for the cb code 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 win

Codeberg 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 value

Consider a page cap on the pagination loops.

while (true) relies solely on the upstream Link header; a misbehaving/proxied response that keeps advertising rel="next" with non-empty data will loop indefinitely. A page <= 20 guard 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

📥 Commits

Reviewing files that changed from the base of the PR and between feb5b93 and 47615bc.

⛔ Files ignored due to path filters (1)
  • web/assets/sponsors/openbin.livrasand.com.png is excluded by !**/*.png
📒 Files selected for processing (10)
  • .env.example
  • LEGAL.md
  • README.md
  • internal/config/config.go
  • internal/git/receive.go
  • internal/http/handlers.go
  • internal/http/router.go
  • internal/provider/codeberg/codeberg.go
  • web/index.html
  • web/repo.html

Comment thread internal/git/receive.go Outdated
Comment thread internal/http/handlers.go Outdated
Comment thread internal/http/handlers.go
Comment thread internal/http/handlers.go
Comment thread internal/provider/codeberg/codeberg.go Outdated
Comment thread web/index.html
Comment thread web/index.html Outdated
Comment thread web/index.html
Comment thread web/repo.html Outdated
Comment thread web/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants