INNER CODE UNIT · Python
fix_branch_references
webartifex/intro-to-python · noxfile.py:58
def fix_branch_references(_session):
"""Change git branch references.
Intended to be run as a pre-commit hook.
Many files in the project (e.g., README.md) contain links to resources on
github.com, nbviewer.jupyter.org, or mybinder.org that contain git branch
labels.
This task rewrites branch labels into either "main" or "develop".
"""
# Glob patterns that expand into the files whose links are re-written.
paths = ["*.md", "**/*.ipynb"]
branch = (
subprocess.check_output(
("git", "rev-parse", "--abbrev-ref", "HEAD"),
)