First working version
This commit is contained in:
parent
cf0516fadc
commit
3c7a7c9caf
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.direnv/
|
||||
**/__pycache__/*
|
||||
result
|
@ -1,11 +1,48 @@
|
||||
import typer
|
||||
import requests
|
||||
from rich.console import Console
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
DEFAULT_HEADERS = {
|
||||
"Accept": "application/vnd.github.text+json",
|
||||
}
|
||||
|
||||
BRANCHES = [ "nixos-unstable-small", "nixos-unstable", "nixos-24.05" ]
|
||||
|
||||
@app.command()
|
||||
def pr(status: str):
|
||||
def pr(pr: str):
|
||||
"""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():
|
||||
app()
|
||||
|
Loading…
Reference in New Issue
Block a user