From d546de52e05732e859f7236dec6094cc01280d6a Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sat, 15 Jun 2024 14:24:56 +0200 Subject: [PATCH] newModuleTagger: init --- newModuleTagger/find_prs.py | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 newModuleTagger/find_prs.py diff --git a/newModuleTagger/find_prs.py b/newModuleTagger/find_prs.py new file mode 100755 index 0000000..330040e --- /dev/null +++ b/newModuleTagger/find_prs.py @@ -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() \ No newline at end of file