From 457f9a3321b7d875d5b3a29920fa3ba630e92c55 Mon Sep 17 00:00:00 2001 From: Updatebot Date: Mon, 26 Aug 2024 08:30:42 -0500 Subject: [PATCH] Add --dry-run CLI argument If the `--dry-run`/`-n` argument is passed, `updatebot` will not push any changes to the remote repository or open/update a pull request. --- updatebot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/updatebot.py b/updatebot.py index 2aaddfb..8edfe53 100644 --- a/updatebot.py +++ b/updatebot.py @@ -220,6 +220,7 @@ class Config(pydantic.BaseModel): class Arguments: config: Path branch_name: str + dry_run: bool projects: list[str] @@ -247,6 +248,7 @@ def parse_args() -> Arguments: default=XDG_CONFIG_HOME / 'updatebot' / 'config.toml', ) parser.add_argument('--branch-name', '-b', default='updatebot') + parser.add_argument('--dry-run', '-n', action='store_true', default=False) parser.add_argument('projects', metavar='project', nargs='*', default=[]) return parser.parse_args(namespace=Arguments()) @@ -321,8 +323,9 @@ def main() -> None: repo, f'refs/remotes/origin/{args.branch_name}' ) ) - repo.remote().push(force=True) - config.repo.create_pr(title, args.branch_name, config.repo.branch) + if not args.dry_run: + repo.remote().push(force=True) + config.repo.create_pr(title, args.branch_name, config.repo.branch) if __name__ == '__main__':