Skip to content

Commit

Permalink
add branch name validation script
Browse files Browse the repository at this point in the history
  • Loading branch information
erenbesel committed Feb 18, 2025
1 parent bb13417 commit 331db2b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Scripts/validate-branch-name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
LC_ALL=C

local_branch="$(git rev-parse --abbrev-ref HEAD)"

valid_branch_regex="^(feature|fix|chore|improvement|release)\/[a-z0-9._-]+$"

message="Invalid branch name. Branch names should follow this format: $valid_branch_regex. Your commit will be rejected. Rename your branch to a valid name and try again."

if [[ ! $local_branch =~ $valid_branch_regex ]]
then
echo "$message"
exit 1
fi

exit 0

0 comments on commit 331db2b

Please sign in to comment.