Skip to content

Commit

Permalink
Added block_branch_names.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Hayato Matsuura committed Sep 23, 2016
1 parent cf11259 commit f58dad2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pre-receive-hooks/block_branch_names.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

#
# Pre-receive hook that will block any new commits that their names contain
# other than lower-case alphabet characters (a-z).
#
# More details on pre-receive hooks and how to apply them can be found on
# https://help.github.com/enterprise/admin/guides/developer-workflow/managing-pre-receive-hooks-on-the-github-enterprise-appliance/
#

zero_commit="0000000000000000000000000000000000000000"

while read oldrev newrev refname; do
# Prevent creation of new branches that don't match `^refs/heads/[a-z]+$`
if [[ $oldrev == $zero_commit && ! $refname =~ ^refs/heads/[a-z]+$ ]]; then
echo "Blocking creation of new branch $refname because it must only contain lower-case alphabet characters."
exit 1
fi
done
exit 0

0 comments on commit f58dad2

Please sign in to comment.