Skip to content

fix: generalize getGithubBaseUrl to support any github-compatible forge#381

Merged
hargoniX merged 3 commits intoleanprover:mainfrom
NicolasRouquette:fix/generalize-git-forge-urls
Apr 13, 2026
Merged

fix: generalize getGithubBaseUrl to support any github-compatible forge#381
hargoniX merged 3 commits intoleanprover:mainfrom
NicolasRouquette:fix/generalize-git-forge-urls

Conversation

@NicolasRouquette
Copy link
Copy Markdown
Contributor

Closes #380

Summary

Generalizes getGithubBaseUrl to accept any HTTPS or SSH git remote URL, not just github.com. This fixes srcUri.github failures for GitHub Enterprise and other git forges.

Changes

lakefile.leangetGithubBaseUrl:

  • SSH remotes: Match any git@<host>:<org>/<repo>.git instead of only git@github.com:…. Extracts host by splitting on :.
  • HTTPS remotes: Match any https://<host>/<org>/<repo>[.git] instead of only https://github.com/…. Validates at least 3 path components (host/org/repo).
  • Updated docstring with supported URL formats and a note about non-GitHub link conventions.

Before / After

Remote URL Before After
https://github.com/org/repo some "https://github.com/org/repo" some "https://github.com/org/repo"
https://ghe.corp.com/org/repo none (error) some "https://ghe.corp.com/org/repo"
git@ghe.corp.com:org/repo.git none (error) some "https://ghe.corp.com/org/repo"
https://codeberg.org/org/repo.git none (error) some "https://codeberg.org/org/repo"

Caveats

Source links use /blob/COMMIT/path (GitHub convention). For Codeberg/Forgejo/Gitea (which use /src/commit/COMMIT/path), the generated links won't resolve — DOCGEN_SRC=file remains the workaround. A follow-up could add a DOCGEN_SRC=url mode or auto-detect the forge type.

Testing

Verified with a project hosted on JPL's GitHub Enterprise

NicolasRouquette and others added 2 commits April 11, 2026 22:53
The original implementation only accepted github.com URLs.
This change generalizes it to accept any HTTPS or SSH git remote:
- https://host/org/repo[.git] (GitHub, GitHub Enterprise, Codeberg, Gitea)
- git@host:org/repo.git (any SSH remote)

This fixes srcUri.github failures for:
- GitHub Enterprise (e.g., github.jpl.nasa.gov)
- Codeberg/Forgejo/Gitea (e.g., codeberg.org)

Note: Source links use GitHub's /blob/COMMIT/path convention.
For non-GitHub forges (Codeberg uses /src/commit/), use DOCGEN_SRC=file.
Co-authored-by: Henrik Böving <hargonix@gmail.com>
@hargoniX
Copy link
Copy Markdown
Collaborator

Thanks for your nice PRs as always!

@hargoniX hargoniX merged commit dcc9a8f into leanprover:main Apr 13, 2026
2 checks passed
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.

srcUri.github fails for GitHub Enterprise and non-GitHub git forges

2 participants