Allow multiple prs in pr command

This commit is contained in:
Torjus Håkestad 2024-12-30 11:02:32 +01:00
parent d1b8c63d60
commit 7686402166
Signed by: torjus
SSH Key Fingerprint: SHA256:KjAds8wHfD2mBYK2H815s/+ABcSdcIHUndwHEdSxml4
3 changed files with 11 additions and 6 deletions

View File

@ -19,7 +19,7 @@ BRANCHES = ["nixos-unstable-small", "nixos-unstable", "nixos-24.05"]
@app.command()
def pr(
pr: int,
pr: list[int],
branches: Annotated[
list[str] | None, typer.Option(help="Check specific branch")
] = None,
@ -28,12 +28,15 @@ def pr(
] = OutputFormat.CONSOLE,
) -> None:
"""Get merge status of pull request."""
if branches:
if isinstance(pr, int):
status = pr_merge_status(pr, branches)
else:
status = pr_merge_status(pr)
status.print(format=format)
return
for pr_ in pr:
status = pr_merge_status(pr_, branches)
status.print(format=format)
print()
@app.command()

View File

@ -75,6 +75,8 @@ def get_pr(pr: int) -> dict[str, Any]:
def pr_merge_status(
pr: int, branches: list[str] = DEFAULT_BRANCHES, check_backport: bool = True
) -> PRStatus:
if not branches:
branches = DEFAULT_BRANCHES
url = f"https://api.github.com/repos/NixOS/nixpkgs/pulls/{pr}"
pr_response = requests.get(url, headers=DEFAULT_HEADERS)
pr_response.raise_for_status()

View File

@ -1,6 +1,6 @@
[project]
name = "nixprstatus"
version = "0.1.15"
version = "0.1.16"
description = "Nixpkgs PR status checker"
readme = "README.md"
requires-python = ">=3.12"