From 768640216642bd45b5a20b5c95283551f39cf8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Mon, 30 Dec 2024 11:02:32 +0100 Subject: [PATCH] Allow multiple prs in pr command --- nixprstatus/__main__.py | 13 ++++++++----- nixprstatus/pr.py | 2 ++ pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/nixprstatus/__main__.py b/nixprstatus/__main__.py index d61495e..d4f74fb 100644 --- a/nixprstatus/__main__.py +++ b/nixprstatus/__main__.py @@ -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 - status.print(format=format) + for pr_ in pr: + status = pr_merge_status(pr_, branches) + status.print(format=format) + print() @app.command() diff --git a/nixprstatus/pr.py b/nixprstatus/pr.py index 654a1f1..6be07a8 100644 --- a/nixprstatus/pr.py +++ b/nixprstatus/pr.py @@ -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() diff --git a/pyproject.toml b/pyproject.toml index 1cf63ab..c536683 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"