From 2565da4fb1e2231da6996283a6bc8eb6e06becfe Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sun, 13 Jul 2008 20:24:03 -0500 Subject: [PATCH] Hook to keep out camel casing. --- cbas/update | 1 + server/update-prefer-underscores | 23 +++++++++++ .../t2600-server-update-prefer-underscores.sh | 39 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 server/update-prefer-underscores create mode 100644 tests/t2600-server-update-prefer-underscores.sh diff --git a/cbas/update b/cbas/update index 885aff4..a4a4374 100755 --- a/cbas/update +++ b/cbas/update @@ -7,5 +7,6 @@ newrev="$3" sh /srv/git/hooks/server/update-trac "$refname" "$oldrev" "$newrev" && sh /srv/git/hooks/server/update-allow-tags-branches "$refname" "$oldrev" "$newrev" && sh /srv/git/hooks/server/update-prefer-rebase "$refname" "$oldrev" "$newrev" && +sh /srv/git/hooks/server/update-prefer-underscores "$refname" "$oldrev" "$newrev" && sh /srv/git/hooks/server/update-stable "$refname" "$oldrev" "$newrev" diff --git a/server/update-prefer-underscores b/server/update-prefer-underscores new file mode 100644 index 0000000..9f9cd29 --- /dev/null +++ b/server/update-prefer-underscores @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Simply enforces rate_tables instead of rateTables. Note +# that ratetables could still sneak when, but we'll give +# people the benefit of the doubt. + +# Command line +refname="$1" +oldrev="$2" +newrev="$3" + +if expr "$oldrev" : '0*$' >/dev/null ; then + if expr "$refname" : '.*[A-Z].*' ; then + echo "----------------------------------------------------" + echo + echo "Please prefer underscored branch names (e.g. rate_tables)" + echo "instead of camel-casing branch names (e.g. rateTables)." + echo + echo "----------------------------------------------------" + exit 1 + fi +fi + diff --git a/tests/t2600-server-update-prefer-underscores.sh b/tests/t2600-server-update-prefer-underscores.sh new file mode 100644 index 0000000..91271ec --- /dev/null +++ b/tests/t2600-server-update-prefer-underscores.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +test_description='server update prefer underscores in branch names' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo "setup" >a && + git add a && + git commit -m "setup" && + git clone ./. server && + rm -fr server/.git/hooks && + git remote add origin ./server && + git config --add branch.master.remote origin && + git config --add branch.master.merge refs/heads/master && + git fetch && + git checkout -b stable && + git push origin stable +' + +install_update_hook 'update-prefer-underscores' + +test_expect_success 'pushing topic_topic works' ' + git checkout -b topic_topic && + echo "$test_name" >a && + git commit -a -m "$test_name on topic_topic" && + git push origin topic_topic +' + +test_expect_success 'pushing topicTopic fails' ' + git checkout -b topicTopic && + echo "$test_name" >a && + git commit -a -m "$test_name on topicTopic" && + ! git push origin topicTopic 2>push.err && + cat push.err | grep "Please prefer underscored branch names" +' + +test_done + -- 2.39.5