Rewrite the Forgejo links instead of GitHub links in the nox session

This commit is contained in:
Alexander Hess 2026-11-24 11:15:20 +01:00
commit abc3ec5b3c
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -40,7 +40,7 @@ import nox
from nox.sessions import Session from nox.sessions import Session
GITHUB_REPOSITORY = 'webartifex/urban-meal-delivery' FORGEJO_REPOSITORY = 'code.webartifex.de/alexander/velofy'
PACKAGE_IMPORT_NAME = 'velofy' PACKAGE_IMPORT_NAME = 'velofy'
# Docs/sphinx locations. # Docs/sphinx locations.
@ -390,7 +390,7 @@ def fix_branch_references(session): # noqa:WPS210
Intended to be run as a pre-commit hook. Intended to be run as a pre-commit hook.
Many files in the project (e.g., README.md) contain links to resources Many files in the project (e.g., README.md) contain links to resources
on github.com or nbviewer.jupyter.org that contain branch labels. on Forgejo that contain branch labels.
This task rewrites these links such that they contain branch references This task rewrites these links such that they contain branch references
that make sense given the context: that make sense given the context:
@ -441,16 +441,9 @@ def fix_branch_references(session): # noqa:WPS210
rewrites = [ rewrites = [
{ {
'name': 'github', 'name': 'forgejo',
'pattern': re.compile( 'pattern': re.compile(
fr'((((http)|(https))://github\.com/{GITHUB_REPOSITORY}/((blob)|(tree))/)([\w\.-]+)/)', # noqa:E501 fr'((https://{FORGEJO_REPOSITORY}/src/branch/)([\w\.-]+)/)',
),
'replacement': fr'\2{branch}/',
},
{
'name': 'nbviewer',
'pattern': re.compile(
fr'((((http)|(https))://nbviewer\.jupyter\.org/github/{GITHUB_REPOSITORY}/((blob)|(tree))/)([\w\.-]+)/)', # noqa:E501
), ),
'replacement': fr'\2{branch}/', 'replacement': fr'\2{branch}/',
}, },