-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(install): Add install script and move hooks
Move hooks to a directory only containing executable hooks. Install script verifies the project to symlink hooks to. Closes: #1
- Loading branch information
Derek Michael Frank
committed
Jul 17, 2016
1 parent
a0a2f35
commit 2417c70
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,48 @@ | ||
#!/bin/sh | ||
|
||
cd "$(dirname $0)" | ||
|
||
githooks="$PWD" | ||
# Ignore githook repository. | ||
project="$(dirname "$githooks")" | ||
found=false | ||
while [ "$found" = false ] && [ "$project" != '/' ]; do | ||
# Can only connect to root of a git project. | ||
if stat "$project/.git" >/dev/null 2>&1; then | ||
echo "Link githooks to project '$(basename $project)'?" | ||
select ans in 'yes' 'no' 'cancel'; do | ||
case $ans in | ||
yes ) | ||
found=true | ||
break;; | ||
no ) | ||
project="$(dirname "$project")" | ||
break;; | ||
cancel ) | ||
echo 'Canceled!' | ||
exit 1 | ||
break;; | ||
* ) | ||
echo 'Please select the number of your answer.' | ||
echo | ||
break;; | ||
esac | ||
done | ||
else | ||
project="$(dirname "$project")" | ||
fi | ||
done | ||
|
||
if [ "$project" = '/' ]; then | ||
echo 'No more projects to try!' | ||
exit 1 | ||
fi | ||
|
||
cd "$project/.git/hooks" | ||
for hook in $githooks/hooks/* ; do | ||
# Create relative symlinks. | ||
hook="${hook/$project/../..}" | ||
if [ -x "$hook" ]; then | ||
ln -s "$hook" "$(basename "$hook")" | ||
fi | ||
done |