forked from rjancewicz/python-kadmin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.sh
executable file
·37 lines (28 loc) · 1.04 KB
/
setup.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
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
CWD=$(pwd)
GIT_SECRET_REPO_DST=$TMPDIR
if [ -f ./.git/hooks/pre-commit ] || [ -f ./.git/hooks/commit-msg ] || [ -f ./.git/hooks/prepare-commit-msg ]; then
echo "ERROR: git hooks exist, please remove them before setting up"
exit 1
fi
if [ ! -d $GIT_SECRET_REPO_DST/git-secrets ] ; then
cd $GIT_SECRET_REPO_DST
git clone https://github.com/awslabs/git-secrets.git
cd git-secrets
sudo make install
cd ..
rm -rf git-secrets
cd $CWD
fi
cp ./hooks/* ./.git/hooks
git secrets --install -f # force install, this will overwrite pre-commit, prepare-commit-msg, and commit-msg in ./hooks
git secrets --register-aws --global # adds the git secrets to the global git config
if [ -f ./hooks/pre-commit ]; then
cat ./hooks/pre-commit | tail -n +2 >> ./.git/hooks/pre-commit
fi
if [ -f ./hooks/commit-msg ]; then
cat ./hooks/commit-msg | tail -n +2 >> ./.git/hooks/commit-msg
fi
if [ -f ./hooks/prepare-commit-msg ]; then
cat ./hooks/prepare-commit-msg | tail -n +2 >> ./.git/hooks/prepare-commit-msg
fi