Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
update install to be less lame
Browse files Browse the repository at this point in the history
before it was a floating script, now it's `git hooks install`
  • Loading branch information
AD7six committed Sep 13, 2011
1 parent e3bd130 commit 0b48700
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 47 deletions.
73 changes: 73 additions & 0 deletions git-hooks
@@ -0,0 +1,73 @@
#!/bin/bash

usage() {
echo "usage: git hooks install"
echo
echo "git-hooks is a php based hook system allowing you to easily configure your hooks"
}

install() {
src=`dirname $(readlink $0)`
dryrun=
ignore='(^\.|^config\.php$|^install|\.txt$|README.md|~$)'

if [ ! -d .git/hooks ]; then
echo "This script needs to be run whilst in the root of your git project"
exit 1
fi

i=0
commands=()
for f in $(ls -A $src 2>/dev/null); do
if [[ $f =~ $ignore ]]; then
continue
fi

if [[ $f = "config.sample.php" ]]; then
if [[ -e .git/hooks/config.php ]]; then
continue
fi
commands[$i]="cp $src/$f .git/hooks/config.php"
else
commands[$i]="ln -sf $src/$f .git/hooks/"
fi
let i++
done

for f in applypatch-msg commit-msg post-commit post-receive post-update pre-applypatch pre-commit prepare-commit-msg pre-rebase update; do
commands[$i]="ln -sf $src/one-hook .git/hooks/$f"
let i++
done

echo "Installing files:"
echo ""
for ((j=0;j<$i;j++)) do
if [ -z $dryrun ]; then
echo " ${commands[$j]}"
else
echo " ${commands[$j]} [dryrun]"
continue
fi
${commands[$j]}
done
echo ""
echo "Completed, edit .git/hooks/config.php to modify this repositories hooks"
exit 0
}

main() {
if [ $# -lt 1 ]; then
usage
exit 1
fi

if [ "$1" == "install" ]; then
install
exit 1
fi

usage
exit 1
}

main "$@"
2 changes: 1 addition & 1 deletion install
Expand Up @@ -4,4 +4,4 @@
dest=/usr/local/bin
src=`pwd`

sudo ln -s $src/installGitHooks $dest && chmod +x $dest/installGitHooks
sudo ln -s $src/git-hooks $dest/ -f && chmod +x $dest/git-hooks
46 changes: 0 additions & 46 deletions installGitHooks

This file was deleted.

0 comments on commit 0b48700

Please sign in to comment.