diff options
| author | Ninson Dobiyas <godclutch958@gmail.com> | 2026-11-26 08:32:29 +0400 |
|---|---|---|
| committer | Ninson Dobiyas <godclutch958@gmail.com> | 2026-11-26 08:32:29 +0400 |
| commit | 9e4b0bab961244b050b31e3238a5ec342ebd3a83 (patch) | |
| tree | b3847c7f5025ac85ff44269cdc69d639a58451d2 /scripts/export_github_metadata.py | |
| parent | b61a6d609842a392dd76592cb57813a8d68bb4e6 (diff) | |
Fix metadata export tests and public-only scope
Diffstat (limited to 'scripts/export_github_metadata.py')
| -rw-r--r-- | scripts/export_github_metadata.py | 9 |
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 | |||
| 14 | from pathlib import Path | 14 | from pathlib import Path |
| 15 | 15 | ||
| 16 | API = "https://api.github.com" | 16 | API = "https://api.github.com" |
| 17 | FIELDS = ("id", "number", "html_url", "state", "title", "created_at", "updated_at", "closed_at") | 17 | FIELDS = ("id", "number", "html_url", "state", "title", "body", "created_at", "updated_at", "closed_at") |
| 18 | COMMENT_FIELDS = ("id", "html_url", "created_at", "updated_at", "body") | 18 | COMMENT_FIELDS = ("id", "html_url", "created_at", "updated_at", "body") |
| 19 | REVIEW_FIELDS = ("id", "html_url", "state", "submitted_at", "body") | 19 | REVIEW_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) |