diff --git a/scripts/adopt-existing.py b/scripts/adopt-existing.py index d647b52..b0d73a1 100755 --- a/scripts/adopt-existing.py +++ b/scripts/adopt-existing.py @@ -200,10 +200,15 @@ def agents_md(repo: str, rep: dict): sys.exit("❌ templates/README.md 里找不到 ```markdown 骨架块") name = repo.split("/")[1] body = m.group(1).replace("", name).replace("/", repo) + # 如实写:默认**不开**分支保护(正本 §1.3)。别把模板里的假设写进别人的仓库 —— + # 一行"已启用分支保护"在没开保护时就是假的,而下一个人会信它。 + branch_line = (f"| 默认分支 | `{rep['default_branch']}` —— 已启用分支保护(禁直推 + 必须 PR) |" + if rep.get("protections") + else f"| 默认分支 | `{rep['default_branch']}` —— **直推**(默认不开分支保护,正本 §1.3) |") facts = "\n".join([ "## 1b. 接入时核实的现状(事实变了就更新;别让它过期)", "", "| 项 | 值 |", "|---|---|", - f"| 默认分支 | `{rep['default_branch']}` —— **已启用分支保护**:禁止直接推送、必须走 PR |", + branch_line, f"| CI | 工作流 {rep['workflows'] or '(无)'};status context {rep['contexts'] or '(无)'} |", f"| Runner | {rep['runners'] or '(无本仓 runner —— 有工作流也会永远 queued)'}{'(' + rep['runners_scope'] + ')' if rep['runners_scope'] else ''} |", "", ]) diff --git a/templates/README.md b/templates/README.md index b0f42c6..1a17e9f 100644 --- a/templates/README.md +++ b/templates/README.md @@ -94,6 +94,7 @@ python3 ~/.hermes/scripts/gitea_api.py GET "/api/v1/repos///actions/ta ## 5. 提交与推送 +- **默认直推 `main`**(原稿口径,正本 §1.1);**需要评审时**才开短命分支 + PR(正本 §1.2,那是**建议**、不是门禁)。 - conventional commits,正文中文,**说清"为什么"**;一件事一个提交。 - 提交信息不要用反引号 / `$()`(会触发命令替换):用 `git commit -F -` + heredoc。 - 推之前跑完第 2 节;推送后用第 3 节确认流水线,失败就**先读 trace 再改代码**。