-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·27 lines (21 loc) · 1.02 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
. "helper.sh"
TMP_DIR=`mktemp -d /tmp/sitebase.hooks.XXXXXXXXXX`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HOOK_PRE_COMMIT="${DIR}/hooks/pre-commit.sh"
HOOK_POST_COMMIT="${DIR}/hooks/post-commit.sh"
HOOK_COMMIT_MSG="${DIR}/hooks/commit-msg.sh"
echo "Install hooks"
# Validations
[ -z $1 ] && echo "${CROSS}${RED} Provide as argument a path to a git repository${WHITE}" && exit 1
REPO_GIT_FOLDER="$1/.git/"
[ ! -d $REPO_GIT_FOLDER ] && echo "${CROSS}${RED} The path you provided doesn't seem to be a Git repository because it doesn't contain a .git folder.${WHITE}" && exit 1
# Remove existing hooks
echo "- Remove existing hooks ..."
rm "$REPO_GIT_FOLDER/hooks/post-commit"
rm "$REPO_GIT_FOLDER/hooks/pre-commit"
rm "$REPO_GIT_FOLDER/hooks/commit-msg"
# Create symlinks
echo "- Create symlinks to the hooks repo ..."
ln -s "$(hooks_dir)pre-commit.sh" "$REPO_GIT_FOLDER/hooks/pre-commit"
ln -s "$(hooks_dir)post-commit.sh" "$REPO_GIT_FOLDER/hooks/post-commit"
ln -s "$(hooks_dir)commit-msg.sh" "$REPO_GIT_FOLDER/hooks/commit-msg"