fix(apply-repo-settings): backfill GitHub's implicit pull_request defaults before diffing - #96
Merged
Conversation
…aults before diffing GitHub backfills two optional pull_request rule parameters that settings.yml often leaves unset: allowed_merge_methods (all three methods — merge, squash, rebase — regardless of what the repo itself allows) and required_reviewers (empty array). Neither default is declared in GitHub's OpenAPI schema or REST docs, so the ruleset diff treated their absence in settings.yml as a permanent mismatch against the live API response, even when nothing was actually misconfigured. Confirmed these defaults empirically rather than assuming them: read live rulesets on both nsheaps/greasemonkey-scripts and nsheaps/.github (which independently have allow_merge_commit:false at the repo level, yet both still return "merge" in allowed_merge_methods), and cross- checked GitHub's REST docs + OpenAPI schema, which state no default for either field. Backfill both fields on current vs. desired before the jq -S comparison (stacked on #95's ruleset-diff fix), only when actually absent so a genuine future restriction still registers as drift. Co-Authored-By: Claude Code (~/src/nsheaps/github-actions) <noreply@anthropic.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.
Summary
allowed_merge_methodsandrequired_reviewersonpull_request-type rules with implicit defaults thatsettings.ymlnever explicitly sets, causing a permanent false "needs update" even when nothing is actually misconfigured.Research (not a guess, per the ask)
Checked both potential sources of a "documented default" and found neither declares one:
repository-rule-pull-request) has nodefault:key onallowed_merge_methodsorrequired_reviewers.Since there's no citable documented default, verified the actual runtime behavior empirically, across two independent repos, rather than assume it:
nsheaps/greasemonkey-scriptsandnsheaps/.githubboth haveallow_merge_commit: falseat the repository level (merge commits disabled) — yet both repos' liverequire-prruleset still returnsallowed_merge_methods: ["merge", "squash", "rebase"](all three, including the disabled one). This rules out the plausible-but-wrong guess that the default mirrors the repo's own merge-method settings — it's a fixed, independent default.required_reviewers: []when unset.Fix
Backfill
allowed_merge_methods→["merge","squash","rebase"]andrequired_reviewers→[]onpull_request-type rules, on bothcurrent_normanddesired_norm, only when the field is actually absent (// default) — so a real, explicit value on either side is never overwritten.Test plan
bash -n+shellcheck— clean.current_norm == desired_normafter the fix.allowed_merge_methodsto["squash"]while current still has all three — confirms this still registers as drift (fix doesn't mask a real future restriction).required_reviewerswhile current is still empty — confirms this still registers as drift.pull_requestrule types (e.g.deletion,non_fast_forward) pass through the filter unmodified, no crash on rules without aparametersblock.@mainby consumers).🤖 Generated with Claude Code