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
parent
22a9b26619
commit
457f9a3321
|
@ -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__':
|
||||
|
|
Loading…
Reference in New Issue