newModuleTagger: init

This commit is contained in:
Oystein Kristoffer Tveit 2024-06-15 14:24:56 +02:00
parent e9866b3b3c
commit d546de52e0
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
1 changed files with 50 additions and 0 deletions

50
newModuleTagger/find_prs.py Executable file
View File

@ -0,0 +1,50 @@
#! /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():
prs = _gh(["pr", "list", "--json", JSON_FIELDS, "--limit", "1000", "--label", "8.has: module (update)"])
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__":
find_prs_without_new_module_tag()