-
-
Save nielsmh/08ae4217f3e0510d38be89357e941de8 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Check a series of commits | |
# Example: | |
# check-commits-client HEAD^..HEAD | |
set -e | |
# --- Safety check | |
if [ -z "${GIT_DIR}" ]; then | |
echo "Don't run this script from the command line." >&2 | |
echo " (if you want, you could supply GIT_DIR then run" >&2 | |
echo " $0 <oldrev>..<newrev>)" >&2 | |
exit 1 | |
fi | |
HOOKS_DIR=${HOOKS_DIR:-${GIT_DIR}/hooks} | |
tmp_msg_file=$(mktemp) | |
tmp_diff_file=$(mktemp) | |
failure=0 | |
finish() { | |
rm -f ${tmp_msg_file} ${tmp_diff_file} | |
} | |
trap finish EXIT | |
hashes=$(git rev-list "$1") | |
for h in ${hashes} | |
do | |
echo Checking $h... >&2 | |
LC_ALL=C git diff ${h}^..${h} > ${tmp_diff_file} | |
${HOOKS_DIR}/check-diff.py ${tmp_diff_file} || failure=1 | |
git cat-file commit ${h} | sed '1,/^$/d' > ${tmp_msg_file} | |
${HOOKS_DIR}/check-message.py ${tmp_msg_file} server || failure=1 | |
done | |
return $failure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment