Skip to content

Commit

Permalink
upd: branch name validation
Browse files Browse the repository at this point in the history
  • Loading branch information
girafffee committed May 20, 2024
1 parent c2f7c90 commit 25bd897
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/branch.name.validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
ref="${GITHUB_REF}"
if [[ "$ref" =~ ^refs/heads/ ]]; then
branch_name="${ref#refs/heads/}"
if ! [[ "$branch_name" =~ ^(main|(release/[0-9]+\.[0-9]+\.[0-9]+)|(issue/[0-9]+)|(suggestion/[0-9]+)|(feature/[a-z0-9\-]+)|(dev/[a-z0-9\-]+))$ ]]; then
if ! [[ "$branch_name" =~ ^(main|(release/[0-9\.]+)|(issue/[0-9]+)|(suggestion/[0-9]+)|(feature/[a-z0-9\-]+)|(dev/[a-z0-9\-]+))$ ]]; then
echo "Invalid branch name: $branch_name"
echo "Allowed patterns: main, release/x.y.z, issue/123, suggestion/123, feature/feature-name, dev/branch-name"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while read local_ref local_sha remote_ref remote_sha; do
branch_name=$(echo "$local_ref" | sed 's|refs/heads/||')

# Regex pattern for allowed branch names
allowed_pattern="^(main|(release/[0-9]+\.[0-9]+\.[0-9]+)|(issue/[0-9]+)|(suggestion/[0-9]+)|(feature/[a-z0-9\-]+)|(dev/[a-z0-9\-]+))$"
allowed_pattern="^(main|(release/[0-9\.]+)|(issue/[0-9]+)|(suggestion/[0-9]+)|(feature/[a-z0-9\-]+)|(dev/[a-z0-9\-]+))$"

# Check if the branch name matches the allowed pattern
if ! [[ "$branch_name" =~ $allowed_pattern ]]; then
Expand Down

0 comments on commit 25bd897

Please sign in to comment.