Repository navigation
Validate branch names on push and in PRs - #908
Conversation
- Add a workflow that comments on newly opened PRs targeting beta when the head branch doesn't match the naming convention - Runs on pull_request_target without checking out PR code; skips bot-authored PRs - Informational only: posts a reminder comment and does not block merging
- Make the issue prefix mandatory in the branch name check, so `<user>/<short-description>` no longer passes - Drop that form from the error message so it matches the accepted formats
- Add a pre-push hook that checks pushed branch names against <user>/<issue-number>-<description> or <user>/NOISSUE-<description> - Skip main, develop, beta, and branch deletions - Mirrors the naming rule in .github/workflows/branch_name.yaml
- Only validate branch names when the push creates a new remote branch - Pushes to branches that already exist on the remote are no longer rejected - Comment updated to document the grandfathering behavior
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
Closes #907
What does this PR do?
Enforces the branch naming convention
<user>/<issue-number>-<short-description>(e.g.francisca/499-fix-navbar-overflow) in two places:.husky/pre-push): rejects pushes that would create a new remote branch whose name doesn't match the convention. Pushes to existing remote branches are allowed, as are deletions and pushes tomain,develop, andbeta..github/workflows/branch_name.yaml): when a PR targetingbetais opened, checks the head branch name and, if it doesn't match, posts an informational comment. The check never blocks the PR. It skips bot-authored PRs.The description must be lowercase letters separated by hyphens. The hook and the workflow use the same regex, and the hook's comment notes they must be kept in sync.
How to test
bun installso the Husky hooks are set up.git switch -c my-feature) and push it withgit push -u origin my-feature. The push should be rejected with the expected format message.git branch -m <user>/907-validate-branch-name) and push again. The push should succeed.betafrom a non-conforming branch. The workflow should post a comment explaining the convention and should not block merging.betafrom a conforming branch. The workflow should log that the name is valid and post no comment.Screenshots
N/A — no UI changes.
Summary by CodeRabbit
betanow receive an informational comment when the branch name does not follow the required format. Bot-authored pull requests are excluded.main,develop, andbetaare exempt.