aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZearin <zearin@gonk.net>2014-04-28 14:40:49 -0400
committerZearin <zearin@gonk.net>2014-04-28 14:40:49 -0400
commit33f47cd3134f21731f19e1260ed8c5ef36ee04d2 (patch)
tree981dde2431c334a6e758cf7e03db878dd378f076
parentfeae1e052ede35ca02a4643e91d60eb33e876bb2 (diff)
downloadgit-hooks-33f47cd3134f21731f19e1260ed8c5ef36ee04d2.tar.gz
git-hooks-33f47cd3134f21731f19e1260ed8c5ef36ee04d2.tar.bz2
Put related functions next to each other
-rwxr-xr-xgit-hooks58
1 files changed, 29 insertions, 29 deletions
diff --git a/git-hooks b/git-hooks
index 8ec9f13..aa55f72 100755
--- a/git-hooks
+++ b/git-hooks
@@ -57,6 +57,30 @@ function list_hooks_in_dir
fi
}
+function list_hooks
+{
+ GITDIR=`git rev-parse --git-dir`
+ cat "${GITDIR}/hooks/pre-commit" 2> /dev/null | grep 'git-hooks' > /dev/null 2> /dev/null
+ if [ $? = 0 ] ; then
+ echo "Git hooks ARE installed in this repository."
+ echo ""
+ else
+ echo "Git hooks are NOT installed in this repository. (Run 'git hooks --install' to install it)"
+ echo ""
+ fi
+
+ echo 'Listing User, Project, and Global hooks:'
+ echo '---'
+ for dir in `hook_dirs`; do
+ echo "${dir}:"
+ for hook in `list_hooks_in_dir "${dir}" 2` ; do
+ echo -n `basename \`dirname "${hook}"\``
+ echo -e "/`basename "${hook}"` \t- `${hook} --about`"
+ done
+ echo ""
+ done
+}
+
function run_hooks
{
dir="${1}"
@@ -138,35 +162,6 @@ git-hooks run "$0" "$@"';
fi
}
-function list_hooks
-{
- GITDIR=`git rev-parse --git-dir`
- cat "${GITDIR}/hooks/pre-commit" 2> /dev/null | grep 'git-hooks' > /dev/null 2> /dev/null
- if [ $? = 0 ] ; then
- echo "Git hooks ARE installed in this repository."
- echo ""
- else
- echo "Git hooks are NOT installed in this repository. (Run 'git hooks --install' to install it)"
- echo ""
- fi
-
- echo 'Listing User, Project, and Global hooks:'
- echo '---'
- for dir in `hook_dirs`; do
- echo "${dir}:"
- for hook in `list_hooks_in_dir "${dir}" 2` ; do
- echo -n `basename \`dirname "${hook}"\``
- echo -e "/`basename "${hook}"` \t- `${hook} --about`"
- done
- echo ""
- done
-}
-
-function report_error {
- echo "Hook failed: $last_run_hook"
- exit 1
-}
-
function installglobal {
TEMPLATE="$HOME/.git-template-with-git-hooks"
if [ ! -d "${TEMPLATE}" ] ; then
@@ -189,6 +184,11 @@ function uninstallglobal {
git config --global --unset init.templatedir
}
+function report_error {
+ echo "Hook failed: $last_run_hook"
+ exit 1
+}
+
case $1 in
run )
if [ ! -z "${GIT_DIR}" ] ; then