70 lines
2.1 KiB
Bash
Executable file
70 lines
2.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
"$(tg --hooks-path)"/pre-commit "$@" || exit $?
|
|
|
|
if echo $(git rev-parse --symbolic-full-name HEAD) | grep -q ^refs/heads/t/; then
|
|
exit 0
|
|
fi
|
|
if [ $(git rev-parse --symbolic-full-name HEAD) = refs/heads/test ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# These are the locations I keep my temporary source and build trees in
|
|
OUTPUT=$(tools/outdir) # generates a build directory name such as
|
|
# ~/Products/ledger
|
|
PRODUCTS=$(dirname "$OUTPUT")
|
|
BASE=$(basename "$OUTPUT")
|
|
|
|
if [ -z "$BASE" ]; then
|
|
TMPDIR=$PWD/pre-commit
|
|
MIRROR=$PWD/pre-commit-mirror
|
|
else
|
|
TMPDIR=$PRODUCTS/$BASE-pre-commit
|
|
MIRROR=$PRODUCTS/$BASE-pre-commit-mirror
|
|
fi
|
|
|
|
# Exit with status 1 if any command below fails
|
|
set -e
|
|
|
|
# Checkout a copy of the current index into MIRROR
|
|
git checkout-index --prefix=$MIRROR/ -af
|
|
|
|
# Remove files from MIRROR which are no longer present in the index
|
|
git diff-index --cached --name-only --diff-filter=D -z HEAD | \
|
|
(cd $MIRROR && xargs -0 rm -f --)
|
|
|
|
# Copy only _changed files_ from MIRROR to TMPDIR, without copying
|
|
# timestamps. This includes copying over new files, and deleting
|
|
# removed ones. This way, "make check" will only rebuild what is
|
|
# necessary to validate the commit.
|
|
rsync -rlpgoDOc --delete --exclude-from=tools/excludes $MIRROR/ $TMPDIR/
|
|
|
|
# Everything else happens in the temporary build tree
|
|
if [ ! -f $TMPDIR/lib/utfcpp/source/utf8.h ]; then
|
|
rsync -a --delete lib/utfcpp/ $TMPDIR/lib/utfcpp/
|
|
fi
|
|
cd $TMPDIR
|
|
|
|
# Make sure there is a current Makefile. Regeneration of Makefile
|
|
# happens automatically, but if myacprep or acprep changes, we want to
|
|
# regenerate everything manually. If the user doesn't have acprep, look
|
|
# for other common autoconf-related script files.
|
|
if [ ! -f Makefile -o \
|
|
Makefile.am -nt Makefile -o \
|
|
configure.ac -nt Makefile -o \
|
|
\( -f acprep -a acprep -nt Makefile \) ]
|
|
then
|
|
if [ -f acprep ]; then
|
|
./acprep --local --warn --pch
|
|
elif [ -f autogen.sh ]; then
|
|
sh autogen.sh && ./configure
|
|
else
|
|
autoreconf && ./configure
|
|
fi
|
|
fi
|
|
|
|
# Finally, (re)build this proposed source tree and see if it passes
|
|
# muster.
|
|
nice -n 20 make -j3 check
|
|
|
|
exit 0
|