Skip to content

fix(scripts): make setup-git-secrets idempotent - #641

Merged
cristim merged 1 commit into
mainfrom
fix/git-secrets-setup-idempotent-296
Oct 6, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/git-secrets-setup-idempotent-296

Conversation

@cristim

@cristim cristim commented Oct 6, 2026

Copy link
Copy Markdown
Member

Closes #296

Adds add_pattern to scripts/setup-git-secrets.sh: it skips a pattern already in secrets.patterns and otherwise runs git secrets --add, so a real error still stops the script (unlike || true). The three self-matching .gitallowed entries are re-anchored on add_pattern '. scripts/test-git-secrets-allowlist.sh now runs setup a second time and checks it succeeds with an unchanged pattern count.

Checks: reproduced on main (run 1 rc=0, run 2 rc=1, GCP/Azure/DB/PEM patterns skipped). With the fix both runs rc=0 and 15 patterns each time. scripts/test-git-secrets-allowlist.sh passes (36 PASS) and fails on main's setup script. shellcheck reports only the pre-existing unused-color-variable warnings.

Note: #295 edits the same section; its PR is stacked on this branch.

git secrets --add exits 1 for an already-registered pattern, so under set -e a
second make setup-git-secrets aborted at the first custom pattern and left
the GCP, Azure, database and PEM detectors unapplied. Register patterns
through add_pattern, which skips ones already present and still fails on a
real error. Add a second-run check to the allowlist self-test.
@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm impact/internal Team-internal only triaged Item has been triaged urgency/this-quarter Within the quarter effort/xs Trivial / one-liner type/bug Defect labels Oct 6, 2026
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 1 minute for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 68 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 4af3b695-bfe0-4958-ac4d-110cee415950
📥 Commits

Reviewing files that changed from the base of the PR and between 3413591 and d3025d4.

📒 Files selected for processing (3)
  • .gitallowed
  • scripts/setup-git-secrets.sh
  • scripts/test-git-secrets-allowlist.sh
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cristim
cristim merged commit 28a87c2 into main Oct 6, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/internal Team-internal only priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scripts): setup-git-secrets aborts half-configured on a second run

1 participant