Last active
September 14, 2022 15:19
-
-
Save justinperkins/e1cccb83fb4a6987d07542588164639d to your computer and use it in GitHub Desktop.
Git pre push hook for branch naming convention validation
This file contains 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
#!/usr/bin/env ruby | |
local_branch = `git rev-parse --abbrev-ref HEAD`.chomp | |
valid_branch_regex = /^(task|chore|feature|fix|text|hotfix|release)\/[a-z0-9._-]{2,30}$/ | |
if local_branch =~ valid_branch_regex | |
exit 0 | |
else | |
puts "Branch name does not match our convention, please make sure it follows this pattern: #{valid_branch_regex}" | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment