fix: allow leading underscore in branch names (valid per git-check-ref-format)#1486
Open
riley-mete-db wants to merge 1 commit into
Open
Conversation
…f-format) Branch names starting with an underscore (e.g. _release/v1.2.3) are valid per git check-ref-format but were rejected by validateBranchName's first-character whitelist. Since setupBranch validates a PR's baseRefName after checkout, the action failed on every open PR targeting such a branch. A leading underscore carries no option-injection risk (only a leading dash does, which is still rejected separately). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
validateBranchName()rejects branch names that start with an underscore, even though they are valid pergit check-ref-format:Underscores are already allowed everywhere in the name except the first character. Because
setupBranch()validates the PR'sbaseRefNameafter checking out an open PR (src/github/operations/branch.ts), the action fails on every open PR targeting a branch like_release/v1.2.3— a common convention for release/internal branches. There is no input that bypasses this path.Fix
Add
_to the first-character class of the whitelist pattern:A leading underscore carries no option-injection risk — only a leading dash does, and that is still rejected separately. All git calls already go through
execFileSync, so there is no shell-interpolation risk either. The error message and doc comments are updated to match.This follows the same pattern as prior fixes relaxing this whitelist for other git-valid characters:
#(#1137),@(#998),+(#1248),,(#1310).Testing
test/validate-branch-name.test.tscovering_release/v1.2.3,_internal, and_wip/feature-xbun test: 770 pass, 0 failbun run typecheck: cleanprettier --checkon changed files: clean🤖 Generated with Claude Code