Skip to content

Chore(workflow): enforce independent PR branches with pre-push guard#595

Merged
ChuxiJ merged 1 commit intoace-step:mainfrom
1larity:chore/workflow-pr-branch-independence
Feb 15, 2026
Merged

Chore(workflow): enforce independent PR branches with pre-push guard#595
ChuxiJ merged 1 commit intoace-step:mainfrom
1larity:chore/workflow-pr-branch-independence

Conversation

@1larity
Copy link
Contributor

@1larity 1larity commented Feb 15, 2026

Summary

Adds an optional local workflow guard to reduce PR cross-pollution (stacked/overlapping feature branches).

Included changes

  • Add .githooks/pre-push

    • Blocks push when current branch is not based on upstream/main
    • Blocks push when branch commits are already present in other remote origin/feat*, origin/fix*, or origin/docs* branches
    • Allows normal push when branch is independent
  • Add scripts/new_pr_branch.ps1

    • Helper to create new PR branches from upstream/main:
      • powershell -File scripts/new_pr_branch.ps1 -BranchName "<name>"

Why

Prevents occurrences of PR cross-pollution where a new PR accidentally included commits from another open PR.
This guard makes that failure mode explicit before push.

Scope / Safety

  • Workflow-only change (no runtime/model/UI behaviour changes)
  • No production code paths modified

Validation

  • Verified branch creation helper works from upstream/main
  • Verified push succeeds for independent branch
  • Verified guard is active via core.hooksPath=.githooks

Summary by CodeRabbit

  • Chores
    • Added development workflow improvements including automated branch validation to ensure PR isolation and prevent unintended cross-branch commits.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

These changes introduce two new scripts for PR branch management: a pre-push git hook that enforces PR isolation by verifying branches are based on upstream/main and detecting commit cross-pollution across remote feature/fix/docs branches, and a PowerShell utility script that creates new PR branches from a specified base reference.

Changes

Cohort / File(s) Summary
PR Branch Management
.githooks/pre-push, scripts/new_pr_branch.ps1
New scripts for PR workflow: pre-push hook validates branch ancestry and detects commit cross-pollution; PowerShell utility creates new PR branches from base reference (default upstream/main).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 With whiskers twitched and branches blessed,
We hook and check each git request,
New scripts ensure our PRs stay clean,
The finest branch flow ever seen! 🌿✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a pre-push guard to enforce independent PR branches and prevent cross-pollution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
scripts/new_pr_branch.ps1 (1)

12-12: Consider replacing Write-Host with Write-Output.

Per PSScriptAnalyzer, Write-Host bypasses the pipeline and can't be suppressed or captured. Write-Output is more versatile for downstream scripting.

Suggested change
-Write-Host "Created '$BranchName' from '$BaseRef'."
+Write-Output "Created '$BranchName' from '$BaseRef'."

@ChuxiJ ChuxiJ merged commit e4c4aee into ace-step:main Feb 15, 2026
3 checks passed
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.

2 participants