Skip to content

feat: add support for Codeberg repos#62

Open
joaopalmeiro wants to merge 2 commits intonrjdalal:mainfrom
joaopalmeiro:feat/add-codeberg-support
Open

feat: add support for Codeberg repos#62
joaopalmeiro wants to merge 2 commits intonrjdalal:mainfrom
joaopalmeiro:feat/add-codeberg-support

Conversation

@joaopalmeiro
Copy link
Copy Markdown

@joaopalmeiro joaopalmeiro commented Apr 20, 2026

Hi! 👋

I maintain two templates on Codeberg (and plan to have more) and I would like to use GitPick as the recommended tool to get a copy of them. Therefore, this PR adds support for Codeberg repos, similar to the other already supported providers.

Considerations

  • Added some tests inspired by the BitBucket ones.
  • Used one of the repos from the Codeberg organization for the new tests. Chose a small repo that have Git tags in order to test the three URL combinations.
  • Manually tested "cloning" one of my template repos using the commands below.
  • Also tested "cloning" one of my private repos (this feature is not well documented yet, but it works).
  • Used AI (Kiro + Claude Opus 4.6) just to review the code I added.
bun run build && bun run dist/index.mjs -i https://codeberg.org/joaopalmeiro/template-rust-script
bun run build && bun run dist/index.mjs https://codeberg.org/joaopalmeiro/template-rust-script tmp

Any feedback, let me know. Thanks!

@nrjdalal
Copy link
Copy Markdown
Owner

Review

Overview

Adds Codeberg as a fourth supported host alongside GitHub/GitLab/Bitbucket. Touches URL parsing (transform-url.ts), help text (bin/index.ts), docs (README.md), and adds 4 dry-run tests against Codeberg/avatars covering src/branch, src/tag, and src/commit URL forms.

What's good

  • Minimal, well-scoped diff. Follows the existing bitbucket pattern symmetrically: PREFIXES entry, Host type, token regex, env-var map (CODEBERG_TOKEN), help/README updates.
  • Test coverage matches precedent. Branch/tag/commit variants are all exercised, modeled on the bitbucket tests.
  • Correct handling of Codeberg's URL shape. /src/{branch,tag,commit}/<ref>/path (Gitea convention) is parsed correctly — stricter than bitbucket's /src/<ref>/path, which is the right call since Codeberg requires the extra segment.
  • package.json keyword and git@codeberg.org: SSH prefix are included — nothing forgotten.

Suggestions / minor issues

  1. Control-flow regression risk (bin/utils/transform-url.ts:111-135). The previous final else was the bitbucket branch; it's now else if (host === \"bitbucket.org\") with codeberg as the terminal else. If a 5th host is ever added to PREFIXES without a matching branch here, URLs will silently fall into the codeberg parser. Safer to make codeberg an explicit else if (host === \"codeberg.org\") and add a final throw new Error(\Unsupported host: ${host}`)` — defensive but cheap.

  2. Silent fallthrough for unknown src paths. https://codeberg.org/owner/repo/src/foo/... (where foo isn't branch/tag/commit) is treated as a full-repo clone. Probably fine, but a user typo would clone 100% of the repo instead of erroring.

  3. URL forms not covered. Codeberg/Gitea also exposes /raw/branch/<ref>/path and /media/branch/<ref>/path (analogous to raw.githubusercontent.com). Fine as a follow-up, but worth noting so it's not presumed done.

  4. Live-repo tests are brittle. Codeberg/avatars tag v1.0.0 and commit c868879… must remain valid. Matches bitbucket test style, so consistent — just a standing caveat.

Risks

Low. Host detection is additive, cloning goes through git ls-remote / git clone which are host-agnostic, and all existing paths are preserved.

Verdict

Approve with optional nits. The control-flow suggestion (#1) is the only one I'd push for before merge; the rest can be follow-ups.

@joaopalmeiro
Copy link
Copy Markdown
Author

Thanks for the review, @nrjdalal!

Is there anything I should change for this PR, sorry?

@nrjdalal
Copy link
Copy Markdown
Owner

I will do a manual review on/before eow, will change myself or let yk

@joaopalmeiro
Copy link
Copy Markdown
Author

I will do a manual review on/before eow, will change myself or let yk

Got it. Thanks!

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