Hook to keep out camel casing.
authorStephen Haberman <stephen@exigencecorp.com>
Mon, 14 Jul 2008 01:24:03 +0000 (20:24 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Mon, 14 Jul 2008 01:24:03 +0000 (20:24 -0500)
cbas/update
server/update-prefer-underscores [new file with mode: 0644]
tests/t2600-server-update-prefer-underscores.sh [new file with mode: 0644]

index 885aff4..a4a4374 100755 (executable)
@@ -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 (file)
index 0000000..9f9cd29
--- /dev/null
@@ -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 (file)
index 0000000..91271ec
--- /dev/null
@@ -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
+