Compare commits
No commits in common. "e00bcba5f10ff96e31a7aea898e59e35f6e54349" and "68f7c3ab434b5c0420234337e5912bdb02849cf2" have entirely different histories.
e00bcba5f1
...
68f7c3ab43
@ -13,7 +13,3 @@ $ nixprstatus 345501
|
|||||||
❌ nixos-24.05
|
❌ nixos-24.05
|
||||||
```
|
```
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
* Support backported commits
|
|
||||||
* JSON output
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import typer
|
import typer
|
||||||
import requests
|
import requests
|
||||||
from typing import Annotated
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
|
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
@ -12,25 +11,10 @@ DEFAULT_HEADERS = {
|
|||||||
BRANCHES = ["nixos-unstable-small", "nixos-unstable", "nixos-24.05"]
|
BRANCHES = ["nixos-unstable-small", "nixos-unstable", "nixos-24.05"]
|
||||||
|
|
||||||
|
|
||||||
def commit_in_branch(commit_sha: str, branch: str) -> bool:
|
|
||||||
url = f"https://api.github.com/repos/NixOS/nixpkgs/compare/{branch}...{commit_sha}"
|
|
||||||
commit_response = requests.get(url, headers=DEFAULT_HEADERS)
|
|
||||||
commit_response.raise_for_status()
|
|
||||||
status = commit_response.json().get("status")
|
|
||||||
|
|
||||||
if status in ["identical", "behind"]:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def pr(
|
def pr(pr: str):
|
||||||
pr: str,
|
|
||||||
branch: Annotated[str | None, typer.Option(help="Check specific branch")] = None,
|
|
||||||
):
|
|
||||||
"""Get status of pull request"""
|
"""Get status of pull request"""
|
||||||
url = f"https://api.github.com/repos/NixOS/nixpkgs/pulls/{pr}"
|
url = f"https://api.github.com/repos/NixOS/nixpkgs/pulls/{pr}"
|
||||||
typer.echo(f"branch {branch}")
|
|
||||||
|
|
||||||
pr_response = requests.get(url, headers=DEFAULT_HEADERS)
|
pr_response = requests.get(url, headers=DEFAULT_HEADERS)
|
||||||
pr_response.raise_for_status()
|
pr_response.raise_for_status()
|
||||||
@ -39,24 +23,7 @@ def pr(
|
|||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
|
|
||||||
merged = pr_data["merged"]
|
if pr_data["merged"] is False:
|
||||||
|
|
||||||
if branch and not merged:
|
|
||||||
console.print(f":x: {branch}")
|
|
||||||
return
|
|
||||||
|
|
||||||
commit_sha = pr_data.get("merge_commit_sha")
|
|
||||||
|
|
||||||
# Check only specified branch
|
|
||||||
if branch:
|
|
||||||
in_branch = commit_in_branch(commit_sha, branch)
|
|
||||||
if in_branch:
|
|
||||||
console.print(f":white_check_mark: {branch}", highlight=False)
|
|
||||||
else:
|
|
||||||
console.print(f":x: {branch}", highlight=False)
|
|
||||||
return
|
|
||||||
|
|
||||||
if not merged:
|
|
||||||
console.print(":x: master", highlight=False)
|
console.print(":x: master", highlight=False)
|
||||||
for branch in BRANCHES:
|
for branch in BRANCHES:
|
||||||
console.print(f":x: {branch}", highlight=False)
|
console.print(f":x: {branch}", highlight=False)
|
||||||
@ -64,12 +31,18 @@ def pr(
|
|||||||
|
|
||||||
console.print(":white_check_mark: master", highlight=False)
|
console.print(":white_check_mark: master", highlight=False)
|
||||||
|
|
||||||
for b in BRANCHES:
|
commit_sha = pr_data["merge_commit_sha"]
|
||||||
in_branch = commit_in_branch(commit_sha, b)
|
|
||||||
if in_branch:
|
for branch in BRANCHES:
|
||||||
console.print(f":white_check_mark: {b}", highlight=False)
|
url = f"https://api.github.com/repos/NixOS/nixpkgs/compare/{branch}...{commit_sha}"
|
||||||
|
commit_response = requests.get(url, headers=DEFAULT_HEADERS)
|
||||||
|
commit_response.raise_for_status()
|
||||||
|
status = commit_response.json().get("status")
|
||||||
|
|
||||||
|
if status in ["identical", "behind"]:
|
||||||
|
console.print(f":white_check_mark: {branch}", highlight=False)
|
||||||
else:
|
else:
|
||||||
console.print(f":x: {b}", highlight=False)
|
console.print(f":x: {branch}", highlight=False)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "nixprstatus"
|
name = "nixprstatus"
|
||||||
version = "0.1.1"
|
version = "0.1.0"
|
||||||
description = "Nixpkgs PR status checker"
|
description = "Nixpkgs PR status checker"
|
||||||
authors = ["Torjus Håkestad <torjus@usit.uio.no>"]
|
authors = ["Torjus Håkestad <torjus@usit.uio.no>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
Loading…
Reference in New Issue
Block a user