38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Ищу источник лендинга simbiot.cil.by в репо git.cil.by (day-тик 2026-10-05)."""
|
|
import json
|
|
import re
|
|
import sys
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
GIT = "https://git.cil.by"
|
|
TOK = re.search(r":([a-f0-9]{40})@", open("/home/hermes/vybirai/.git/config", errors="ignore").read()).group(1)
|
|
|
|
def api(path):
|
|
req = urllib.request.Request(f"{GIT}/api/v1{path}", headers={"Authorization": f"token {TOK}"})
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=10) as r:
|
|
return r.status, json.loads(r.read())
|
|
except urllib.error.HTTPError as e:
|
|
return e.code, e.read().decode(errors="ignore")[:150]
|
|
|
|
repo = sys.argv[1] if len(sys.argv) > 1 else "symbiot/portal"
|
|
br = sys.argv[2] if len(sys.argv) > 2 else None
|
|
if not br:
|
|
st, info = api(f"/repos/{repo}")
|
|
br = info.get("default_branch", "main")
|
|
|
|
st, commits = api(f"/repos/{repo}/commits?limit=10&sha={br}")
|
|
print(f"== {repo}@{br}: последние коммиты ({st})")
|
|
if isinstance(commits, list):
|
|
for c in commits:
|
|
msg = c["commit"]["message"].split("\n")[0][:90]
|
|
print(f" {c['sha'][:8]} {c['commit']['author']['date'][:16]} {msg}")
|
|
|
|
st, tree = api(f"/repos/{repo}/git/trees/{br}?recursive=1")
|
|
print(f"== дерево ({st})")
|
|
if isinstance(tree, dict):
|
|
for t in tree.get("tree", []):
|
|
if t["type"] == "blob":
|
|
print(f" {t['path']}")
|