fix(update-major-tag): freeze lease from post-fetch local ref#236
fix(update-major-tag): freeze lease from post-fetch local ref#236
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe composite action now captures the current major tag reference locally after the initial Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🔍 Lint Analysis
|
🛡️ CodeQL Analysis ResultsLanguages analyzed: ✅ No security issues found. 🔍 View full scan logs | 🛡️ Security tab |
GitHub Actions Shared Workflows
Description
Follow-up to PR #235. CodeRabbit flagged a critical flaw in that first lease implementation (comment on PR #233, line 73): reading the lease from
git ls-remoteimmediately before the push defeats the protection.The race the old code allowed
LATEST=v1.26.0, reaches the push step.LATEST=v1.27.0, and force-pushesv1 → SHA_NEWfirst.git ls-remoteforrefs/tags/v1and reads backSHA_NEW(B's value).SHA_NEWas its lease — which matches the server — so the server accepts A's push, rewindingv1toSHA_OLD.The fix anterior só "parecia" proteger; o lease sempre convergia com o valor servidor no momento do push.
Fix
Capture the lease once, right after the initial
git fetch --tags --force --prune, from the local ref viagit rev-parse "refs/tags/$MAJOR". This freezes the lease to the state we observed when making the decision to push. If any other run updates$MAJORbetween our fetch and our push, the server's value no longer matches our frozen lease and the push aborts — exactly the desired semantics.Also switched from
git rev-list -n1(commit SHA) togit rev-parse(ref SHA) for the lease, since--force-with-leasecompares ref values — for annotated tags those differ.Affected file:
src/config/update-major-tag/action.ymlType of Change
feat: New workflow or new input/output/step in an existing workflowfix: Bug fix in a workflow (incorrect behavior, broken step, wrong condition)perf: Performance improvement (e.g. caching, parallelism, reduced steps)refactor: Internal restructuring with no behavior changedocs: Documentation only (README, docs/, inline comments)ci: Changes to self-CI (workflows under.github/workflows/that run on this repo)chore: Dependency bumps, config updates, maintenancetest: Adding or updating testsBREAKING CHANGE: Callers must update their configuration after this PRBreaking Changes
None. The zero-SHA fallback for the first-ever tag creation is preserved.
Testing
@developor the beta tagCaller repo / workflow run: Next
mainrelease on this repo will exercise the composite end-to-end.Related Issues
Corrects #235 — surfaced by CodeRabbit critical-severity review on PR #233.
Summary by CodeRabbit