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.
master
Updatebot 2024-08-26 08:30:42 -05:00 committed by Dustin C. Hatch
parent 22a9b26619
commit 457f9a3321
1 changed files with 5 additions and 2 deletions

View File

@ -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,6 +323,7 @@ def main() -> None:
repo, f'refs/remotes/origin/{args.branch_name}'
)
)
if not args.dry_run:
repo.remote().push(force=True)
config.repo.create_pr(title, args.branch_name, config.repo.branch)