This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
forked from s0enke/git-hooks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
before it was a floating script, now it's `git hooks install`
- Loading branch information
Showing
3 changed files
with
74 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.