upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/export_github_metadata.py
diff options
context:
space:
mode:
authorNinson Dobiyas <godclutch958@gmail.com>2026-11-26 08:32:29 +0400
committerNinson Dobiyas <godclutch958@gmail.com>2026-11-26 08:32:29 +0400
commit9e4b0bab961244b050b31e3238a5ec342ebd3a83 (patch)
treeb3847c7f5025ac85ff44269cdc69d639a58451d2 /scripts/export_github_metadata.py
parentb61a6d609842a392dd76592cb57813a8d68bb4e6 (diff)
Fix metadata export tests and public-only scope
Diffstat (limited to 'scripts/export_github_metadata.py')
-rw-r--r--scripts/export_github_metadata.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/export_github_metadata.py b/scripts/export_github_metadata.py
index 6e8905df6..9ed8e381f 100644
--- a/scripts/export_github_metadata.py
+++ b/scripts/export_github_metadata.py
@@ -14,7 +14,7 @@ import urllib.request
14from pathlib import Path 14from pathlib import Path
15 15
16API = "https://api.github.com" 16API = "https://api.github.com"
17FIELDS = ("id", "number", "html_url", "state", "title", "created_at", "updated_at", "closed_at") 17FIELDS = ("id", "number", "html_url", "state", "title", "body", "created_at", "updated_at", "closed_at")
18COMMENT_FIELDS = ("id", "html_url", "created_at", "updated_at", "body") 18COMMENT_FIELDS = ("id", "html_url", "created_at", "updated_at", "body")
19REVIEW_FIELDS = ("id", "html_url", "state", "submitted_at", "body") 19REVIEW_FIELDS = ("id", "html_url", "state", "submitted_at", "body")
20 20
@@ -98,13 +98,16 @@ def main():
98 parser.add_argument("--output", type=Path, required=True) 98 parser.add_argument("--output", type=Path, required=True)
99 args = parser.parse_args() 99 args = parser.parse_args()
100 try: 100 try:
101 data = export(args.repository, os.environ.get("GITHUB_TOKEN")) 101 # Unauthenticated requests prevent exporting a private repository using a
102 # token inherited from the environment.
103 data = export(args.repository)
102 # Atomic replacement: API errors never leave a partial output presented as complete. 104 # Atomic replacement: API errors never leave a partial output presented as complete.
103 target = args.output 105 target = args.output
104 target.parent.mkdir(parents=True, exist_ok=True) 106 target.parent.mkdir(parents=True, exist_ok=True)
105 temp = target.with_name(target.name + ".tmp") 107 temp = target.with_name(target.name + ".tmp")
106 try: 108 try:
107 temp.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") 109 with temp.open("w", encoding="utf-8", newline="\n") as stream:
110 stream.write(json.dumps(data, indent=2, ensure_ascii=False) + "\n")
108 temp.replace(target) 111 temp.replace(target)
109 finally: 112 finally:
110 temp.unlink(missing_ok=True) 113 temp.unlink(missing_ok=True)