-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrefresh_specs.py
More file actions
34 lines (27 loc) · 1002 Bytes
/
Copy pathrefresh_specs.py
File metadata and controls
34 lines (27 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Re-vendor the server OpenAPI specs at the SHAs pinned in manifest.json.
Usage: `python tests/compat/refresh_specs.py` (needs `gh` auth for the source repo)."""
from __future__ import annotations
import json
import subprocess
from pathlib import Path
_DIR = Path(__file__).parent / "server_specs"
def main() -> None:
manifest = json.loads((_DIR / "manifest.json").read_text())
repo, path = manifest["source_repo"], manifest["source_path"]
for entry in manifest["specs"]:
content = subprocess.run(
[
"gh",
"api",
f"repos/{repo}/contents/{path}?ref={entry['sha']}",
"-H",
"Accept: application/vnd.github.raw",
],
check=True,
capture_output=True,
text=True,
).stdout
(_DIR / entry["file"]).write_text(content)
print(f"wrote {entry['file']} from {repo}@{entry['sha'][:12]}")
if __name__ == "__main__":
main()