forked from rook/rook
Afte pylint was updated to version 3.2.0 a set of new errors appeared. This makes ci passing by either fixing the problem or ignoring it in the check Signed-off-by: NymanRobin <robin.nyman@est.tech>
34 lines
697 B
Python
34 lines
697 B
Python
#!/usr/bin/env python3
|
|
|
|
from pygit2 import Repository
|
|
import re
|
|
|
|
"""
|
|
GitHub branch/tag URL replacer
|
|
"""
|
|
|
|
regex = r"(github\.com/.+/rook/.+)/master/"
|
|
subst = "\\1/%s/"
|
|
|
|
|
|
def define_env(env):
|
|
target = None
|
|
repo = Repository(".")
|
|
if repo is not None:
|
|
target = repo.head.shorthand
|
|
|
|
env.variables["current_branch"] = target
|
|
|
|
|
|
def on_post_page_macros(env):
|
|
"""
|
|
Replace the branch/tag in the rook GitHub file and directory links pointing to `master`
|
|
with the correct one that is currently active.
|
|
"""
|
|
|
|
target = env.variables["current_branch"]
|
|
if target == "master":
|
|
return
|
|
|
|
env.raw_markdown = re.sub(regex, subst % target, env.raw_markdown, 0)
|