Repository navigation
repo: fix the helper that applies the governance files - #10
Merged
Merged
Conversation
Applying governance/repository-settings.json to a repository whose squash strategy is off failed with 422 no_squash_merge_strategy: the file still carried squash_merge_commit_message, squash_merge_commit_title and merge_commit_title, and GitHub refuses to set those for a strategy that is disabled. That is how this repository's live settings drifted from the file that is supposed to describe them -- the merge methods were the only part of the payload that ever landed. Send the three fields only when the matching strategy is enabled and the file still lists them, and drop them from the file (they describe a strategy this repository no longer offers). A squash-enabled fork can put them back and the script will send them again; the guard is what makes either choice work. Verified by running the guard against the committed file (no fields sent), a synthetic squash-enabled file (both squash fields sent) and a merge-commit-enabled file (merge_commit_title sent). Signed-off-by: cadywang <cadywang@users.noreply.github.com>
-DryRun promises to print the API calls without touching GitHub, but the remote add/set-url and the "git branch -M main" ran before that guard: a dry run renamed whatever branch the maintainer happened to be on -- the branch he was reviewing, not the one being published. Move both into the branch that actually pushes. A dry run now reads the settings files, prints the calls and stops. Signed-off-by: cadywang <cadywang@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
起因是把
governance/里的设置真正应用到仓库时被 GitHub 拒了:1.
PATCH /repos/...报 422no_squash_merge_strategy治理文件里还留着
squash_merge_commit_message/squash_merge_commit_title/merge_commit_title,而 squash 已经关闭——GitHub 不允许给已关闭的合并策略设置这些字段,于是整个 PATCH 失败,
只有合并方式那几项在早先单独生效过。这正是「治理文件与线上漂移」的根源:脚本一跑就 422,
后面的字段一个都没落地。现在只发送当前启用且有值的字段(squash 开则发 squash 两项、
merge commit 开则发
merge_commit_title),治理文件也不再保留这三项。2.
-DryRun会改名本地分支git remote add/set-url与git branch -M main写在 dry-run 判断之外:文档说 dry-run「只打印 API 调用」,实际却会把当前分支(比如正在评审的那个)改名成
main。现在这两步只在真正推送时执行。线上状态(本 PR 之外已单独对齐,供参考):
main的必需检查 6 个(含PR gate)、delete_branch_on_merge=true、只允许 Rebase and merge、topics/description 已按治理文件设置。本 PR 的提交:
tools: keep a dry run from touching the local checkoutrepo: stop sending squash settings GitHub rejects变更类型
影响面清单
测试
守卫逻辑(直接从
tools/create-github-repo.ps1抽出真实代码块跑,不是复刻):-DryRun端到端(真实执行脚本):其余门禁:
all .ps1 parse OK、python -m compileall0、YAML+JSON 解析、无 BOM/CR、
git diff --check干净、commit 规范 2/2、pr-gate自测 18/18、commit 门禁自测 18/18。bash tests/verify-live.sh <client>:<port>设备与链路信息(涉及传输改动时必填):
base64/awk/od/md5sum)合并前清单
PROTOCOL.md与agent/*、cli/*四个实现已同步更新.tmp-*/、*.log、__pycache__/)<subsystem>: 祈使句摘要、正文 72 列折行,并带Signed-off-by:(git commit -s)<subsystem>: 祈使句摘要>(网页端 squash 会把它写成提交标题)CHANGELOG.md(如面向用户的行为有变化)SECURITY.md(不引入默认对外暴露、无鉴权的行为)关联 Issue
无独立 Issue。起因:对齐线上仓库设置时
PATCH被 422 拒掉,顺带发现-DryRun会改本地分支。