summaryrefslogtreecommitdiffstats
path: root/scripts/qt/branch_qt.py
diff options
context:
space:
mode:
authorIikka Eklund <iikka.eklund@qt.io>2022-02-18 13:49:02 +0200
committerIikka Eklund <iikka.eklund@qt.io>2022-03-14 08:28:31 +0200
commitd0cccfcbbb718baa949cc13898c094626fe3264e (patch)
tree1dcf46df7efeac209f9dd02133bddc5790777614 /scripts/qt/branch_qt.py
parentf6765deb476c99ab2a72cf5390ed8a5593ef3c27 (diff)
branch_qt.py: Make future additions to "mode" more scalable
Put the execution modes and their descriptions into a dictionary and use that to populate the Mode enum and ArgumentParser help. Now you need to make future additions to "mode" only in one place. Change-Id: I34a96fbed72a037c700dfe7f5e3d37fad5720b26 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Diffstat (limited to 'scripts/qt/branch_qt.py')
-rwxr-xr-xscripts/qt/branch_qt.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/scripts/qt/branch_qt.py b/scripts/qt/branch_qt.py
index dec33615..4e813ba6 100755
--- a/scripts/qt/branch_qt.py
+++ b/scripts/qt/branch_qt.py
@@ -25,7 +25,21 @@ from pathlib import Path
import git # type: ignore
-Mode = Enum("Mode", "branch sync merge bump")
+_parser_modes = {
+ "branch": """start soft branching: create the "to" branch based on the "from" branch
+ branch_qt.py -m branch --from 5.12 --to 5.12.4
+ Now 5.12.4 will exist, based on 5.12.""",
+ "sync": """intermediate sync, to update a branch during soft-branching
+ branch_qt.py -m sync --from 5.12 --to 5.12.4
+ Move the new branch fast-forward, assuming only 5.12 has new commits.""",
+ "merge": """down-merge
+ branch_qt.py -m merge --from 5.12 --to 5.12.4
+ Merges 5.12 into 5.12.4.""",
+ "bump": """version bump, to move from 5.12.3 to 5.12.4:
+ branch_qt.py -m bump --from dev --version 5.12.0 --to 5.13.0""",
+}
+
+Mode = Enum("Mode", " ".join(_parser_modes.keys()))
qt5_extra_repositories = [
"qt/qtcoap",
@@ -547,6 +561,7 @@ def parse_args() -> argparse.Namespace:
formatter_class=argparse.RawTextHelpFormatter,
description="Do various merge operations on Qt repositories",
)
+
parser.add_argument(
"--mode",
"-m",
@@ -554,20 +569,7 @@ def parse_args() -> argparse.Namespace:
dest="_mode",
choices=[m.name for m in Mode],
required=True,
- help=dedent(
- """\
- branch - start soft branching: create the "to" branch based on the "from" branch
- branch_qt.py -m branch --from 5.12 --to 5.12.4
- Now 5.12.4 will exist, based on 5.12.
- sync - intermediate sync, to update a branch during soft-branching
- branch_qt.py -m sync --from 5.12 --to 5.12.4
- Move the new branch fast-forward, assuming only 5.12 has new commits.
- merge - down-merge
- branch_qt.py -m merge --from 5.12 --to 5.12.4
- Merges 5.12 into 5.12.4.
- bump - version bump, to move from 5.12.3 to 5.12.4:
- branch_qt.py -m bump --from dev --version 5.12.0 --to 5.13.0"""
- ),
+ help="\n".join(f"{k} - {v}" for k, v in _parser_modes.items()),
)
parser.add_argument("--from", "-f", required=True, type=str, dest="fromBranch")
parser.add_argument("--version", "-v", required=False, type=str, dest="fromVersion")