2024-06-15 14:24:56 +02:00
|
|
|
#! /usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i python3 -p python3 gh
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
import subprocess
|
|
|
|
import json
|
|
|
|
|
|
|
|
def _gh(args: list[str]) -> str | None:
|
|
|
|
try:
|
|
|
|
return subprocess.check_output(["gh", *args], text=True)
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
JSON_FIELDS = ','.join([
|
|
|
|
"files",
|
|
|
|
"author",
|
|
|
|
"title",
|
|
|
|
"number",
|
|
|
|
"labels",
|
|
|
|
"url"
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
def print_pr(pr):
|
|
|
|
print(f'[{pr["number"]}] {pr["author"]["login"]} - {pr["title"]}')
|
|
|
|
print(pr["url"])
|
|
|
|
print(f'Files:')
|
|
|
|
for file in pr["files"]:
|
|
|
|
print(f' {file}')
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
def find_prs_without_new_module_tag():
|
2024-11-05 22:54:04 +01:00
|
|
|
prs = _gh(["pr", "list", "--json", JSON_FIELDS, "--limit", "50", "--label", "8.has: module (update)"])
|
|
|
|
if prs is None:
|
|
|
|
print("gh exited with error")
|
|
|
|
exit(1)
|
2024-06-15 14:24:56 +02:00
|
|
|
prs = json.loads(prs)
|
|
|
|
for pr in reversed(prs):
|
|
|
|
if any(label["name"] == "8.has: module (new)" for label in pr["labels"]):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if not any(file['path'].startswith("nixos/modules/") and not Path(file['path']).exists() for file in pr['files']):
|
|
|
|
continue
|
|
|
|
|
|
|
|
print_pr(pr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-11-05 22:54:04 +01:00
|
|
|
find_prs_without_new_module_tag()
|
|
|
|
|