mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
Mechanically re-derived: bin/debrand runs over a fresh import of posthog/posthog@fa1a9a60d4 (2026-08-06). The pipeline (.hanzo/workflows), the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md and the squashed initial migration are restored from the shipped tree, same as the previous import. The prune's import-closure guard kept 21 products the new core now imports; dropping them is a refactor now, recorded rather than forced.
22 lines
854 B
Python
22 lines
854 B
Python
def read_pr_urls(output: object) -> list[str]:
|
|
if not isinstance(output, dict):
|
|
return []
|
|
|
|
raw_urls = output.get("pr_urls")
|
|
urls: list[object] = raw_urls if isinstance(raw_urls, list) else []
|
|
pr_url = output.get("pr_url")
|
|
candidates = [*urls, pr_url]
|
|
return list(dict.fromkeys(url for url in candidates if isinstance(url, str) and url))
|
|
|
|
|
|
def merge_pr_output(existing: object, incoming: dict) -> dict:
|
|
current = existing if isinstance(existing, dict) else {}
|
|
merged = {**current, **incoming}
|
|
urls = list(dict.fromkeys([*read_pr_urls(incoming), *read_pr_urls(current)]))
|
|
if not urls:
|
|
return merged
|
|
|
|
primary = incoming.get("pr_url") or current.get("pr_url") or urls[0]
|
|
ordered = [primary, *(url for url in urls if url != primary)]
|
|
return {**merged, "pr_url": primary, "pr_urls": ordered}
|