Skip to content

Instantly share code, notes, and snippets.

@justinperkins
Last active September 14, 2022 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinperkins/e1cccb83fb4a6987d07542588164639d to your computer and use it in GitHub Desktop.
Save justinperkins/e1cccb83fb4a6987d07542588164639d to your computer and use it in GitHub Desktop.
Git pre push hook for branch naming convention validation
#!/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