Adjust the branch reference fixer task's logic ...
... to assume a feature branch if the branch name does not start with 'release' or 'research' and change all references into 'develop'.
This commit is contained in:
parent
03e498cab9
commit
51bb7e8235
1 changed files with 14 additions and 4 deletions
18
noxfile.py
18
noxfile.py
|
@ -328,7 +328,7 @@ def test_suite(session):
|
||||||
|
|
||||||
|
|
||||||
@nox.session(name='fix-branch-references', python=PYTHON, venv_backend='none')
|
@nox.session(name='fix-branch-references', python=PYTHON, venv_backend='none')
|
||||||
def fix_branch_references(session): # noqa:WPS210
|
def fix_branch_references(session): # noqa:WPS210,WPS231
|
||||||
"""Replace branch references with the current branch.
|
"""Replace branch references with the current branch.
|
||||||
|
|
||||||
Intended to be run as a pre-commit hook.
|
Intended to be run as a pre-commit hook.
|
||||||
|
@ -336,9 +336,15 @@ def fix_branch_references(session): # noqa:WPS210
|
||||||
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 github.com or nbviewer.jupyter.org that contain branch labels.
|
||||||
|
|
||||||
This task rewrites these links such that they contain the branch reference
|
This task rewrites these links such that they contain branch references
|
||||||
of the current branch. If the branch is only a temporary one that is to be
|
that make sense given the context:
|
||||||
merged into the 'main' branch, all references are adjusted to 'main' as well.
|
|
||||||
|
- If the branch is only a temporary one that is to be merged into
|
||||||
|
the 'main' branch, all references are adjusted to 'main' as well.
|
||||||
|
|
||||||
|
- If the branch is not named after a default branch in the GitFlow
|
||||||
|
model, it is interpreted as a feature branch and the references
|
||||||
|
are adjusted into 'develop'.
|
||||||
|
|
||||||
This task may be called with one positional argument that is interpreted
|
This task may be called with one positional argument that is interpreted
|
||||||
as the branch to which all references are changed into.
|
as the branch to which all references are changed into.
|
||||||
|
@ -362,6 +368,10 @@ def fix_branch_references(session): # noqa:WPS210
|
||||||
# into 'main', we adjust all branch references to 'main' as well.
|
# into 'main', we adjust all branch references to 'main' as well.
|
||||||
if branch.startswith('release') or branch.startswith('research'):
|
if branch.startswith('release') or branch.startswith('research'):
|
||||||
branch = 'main'
|
branch = 'main'
|
||||||
|
# If the current branch appears to be a feature branch, we adjust
|
||||||
|
# all branch references to 'develop'.
|
||||||
|
elif branch != 'main':
|
||||||
|
branch = 'develop'
|
||||||
# If a "--branch=BRANCH_NAME" argument is passed in
|
# If a "--branch=BRANCH_NAME" argument is passed in
|
||||||
# as the only positional argument, we use BRANCH_NAME.
|
# as the only positional argument, we use BRANCH_NAME.
|
||||||
# Note: The --branch is required as session.posargs contains
|
# Note: The --branch is required as session.posargs contains
|
||||||
|
|
Loading…
Reference in a new issue