First working version

This commit is contained in:
Torjus Håkestad 2024-09-30 23:53:30 +02:00
parent cf0516fadc
commit 3c7a7c9caf
2 changed files with 42 additions and 2 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.direnv/
**/__pycache__/*
result

View File

@ -1,11 +1,48 @@
import typer import typer
import requests
from rich.console import Console
app = typer.Typer() app = typer.Typer()
DEFAULT_HEADERS = {
"Accept": "application/vnd.github.text+json",
}
BRANCHES = [ "nixos-unstable-small", "nixos-unstable", "nixos-24.05" ]
@app.command() @app.command()
def pr(status: str): def pr(pr: str):
"""Get status of pull request""" """Get status of pull request"""
typer.echo(f"Pull Request Status: {status}") url = f"https://api.github.com/repos/NixOS/nixpkgs/pulls/{pr}"
pr_response = requests.get(url, headers=DEFAULT_HEADERS)
pr_response.raise_for_status()
pr_data = pr_response.json()
console = Console()
if pr_data["merged"] == False:
console.print(f":x: master", highlight=False)
for branch in BRANCHES:
console.print(f":x: {branch}", highlight=False)
return
console.print(f":white_check_mark: master", highlight=False)
commit_sha = pr_data["merge_commit_sha"]
for branch in BRANCHES:
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:
console.print(f":x: {branch}", highlight=False)
def main(): def main():
app() app()