Skip to content

Commit

Permalink
Add pre-commit git hooks and script to install it
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaixiang committed Oct 12, 2017
1 parent ef38555 commit 2d38d17
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
modified_packages=$(./scripts/sync-package-specs)

if [ -n "$modified_packages" ]; then
echo $'\e[31mthe following package specs are not staged:\e[0m'
echo
echo "$modified_packages"
exit 1
fi


18 changes: 18 additions & 0 deletions scripts/install-git-hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

RELEASE=$(cd $(dirname $0)/.. && pwd)
PRE_COMMIT=${RELEASE}/.git/hooks/pre-commit


if [ ! -f ${PRE_COMMIT} ]; then
echo "#!/bin/bash" > ${PRE_COMMIT}
chmod +x ${PRE_COMMIT}
fi

if grep -q 'git-hooks/pre-commit' ${PRE_COMMIT}; then
echo "pre-commit already installed."
else
echo >> ${PRE_COMMIT}
echo './git-hooks/pre-commit' >> ${PRE_COMMIT}
echo "pre-commit installed."
fi

0 comments on commit 2d38d17

Please sign in to comment.