()
| 481 | # --------------------------------------------------------------------------- |
| 482 | |
| 483 | def build_parser(): |
| 484 | fmt = lambda prog: argparse.RawDescriptionHelpFormatter(prog, width=120) |
| 485 | parser = argparse.ArgumentParser( |
| 486 | description=__doc__, |
| 487 | epilog="For options on each subcommand run: logchange.py <subcommand> --help", |
| 488 | formatter_class=fmt, |
| 489 | ) |
| 490 | sub = parser.add_subparsers(dest="subcommand", required=True) |
| 491 | |
| 492 | common = argparse.ArgumentParser(add_help=False) |
| 493 | common.add_argument("--version", required=True, |
| 494 | help="Release version, e.g. 10.1.0") |
| 495 | common.add_argument("--release-branch", required=True, |
| 496 | help="Release branch, e.g. branch_10_1") |
| 497 | common.add_argument("--gradle-cmd", default="./gradlew", |
| 498 | help="Gradle wrapper command (default: ./gradlew)") |
| 499 | common.add_argument("--git-remote", default="origin", |
| 500 | help="Git remote name to push to (default: origin)") |
| 501 | common.add_argument("--dry-run", action="store_true", |
| 502 | help="Print actions without executing or modifying anything") |
| 503 | |
| 504 | # prepare |
| 505 | p = sub.add_parser("prepare", parents=[common], |
| 506 | help="Prepare changelog for an RC (RC1 or RC2+)", |
| 507 | description="Prepare the changelog for a release candidate.\n" |
| 508 | "RC1: runs 'gradlew logchangeRelease' to move all unreleased entries to the version folder.\n" |
| 509 | "RC2+: copies only new unreleased entries into the existing version folder.\n" |
| 510 | "In both cases CHANGELOG.md is regenerated. By default changes are left uncommitted for review.", |
| 511 | formatter_class=fmt) |
| 512 | p.add_argument("--commit", action="store_true", |
| 513 | help="Stage and commit the result (default: leave uncommitted for review)") |
| 514 | p.add_argument("--rc-number", type=int, default=1, |
| 515 | help="RC number (default: 1). RC2+ appends ' RC<n>' to commit messages.") |
| 516 | p.add_argument("--skip-validation", action="store_true", |
| 517 | help="Skip pre-flight YAML validation of changelog/unreleased/ files") |
| 518 | p.set_defaults(func=cmd_prepare) |
| 519 | |
| 520 | # forward-port |
| 521 | fp = sub.add_parser("forward-port", parents=[common], |
| 522 | help="Set release date and forward-port changelog post-vote", |
| 523 | description="Run once after a successful vote.\n" |
| 524 | "Writes the release date to the version folder and regenerates CHANGELOG.md.\n" |
| 525 | "Then cherry-picks all changelog commits from the release branch to the stable branch and main.\n" |
| 526 | "By default nothing is pushed; review first and pass --push when satisfied.", |
| 527 | formatter_class=fmt) |
| 528 | fp.add_argument("--stable-branch", required=True, |
| 529 | help="Stable branch, e.g. branch_10x") |
| 530 | fp.add_argument("--latest-lts-stable-branch", |
| 531 | help="Also forward-port to this LTS stable branch, e.g. branch_9x (LTS releases only)") |
| 532 | fp.add_argument("--release-date", |
| 533 | help="Release date YYYY-MM-DD (default: today)") |
| 534 | fp.add_argument("--push", action="store_true", |
| 535 | help="Push all branches after cherry-picking (default: leave for review)") |
| 536 | fp.set_defaults(func=cmd_forward_port) |
| 537 | |
| 538 | return parser |
| 539 | |
| 540 |
no outgoing calls
no test coverage detected
searching dependent graphs…