summaryrefslogtreecommitdiff
path: root/tools/pre-commit
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-20 13:31:32 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-20 15:41:43 -0400
commitd167724bac399178ef94180ea5cc297539fefe05 (patch)
tree94901aeeb5d7bde36fe2bdfc86a98e323e07f593 /tools/pre-commit
parent740cd8e8f13a52084b7812246221b2d658bcfc84 (diff)
downloadfork-ledger-d167724bac399178ef94180ea5cc297539fefe05.tar.gz
fork-ledger-d167724bac399178ef94180ea5cc297539fefe05.tar.bz2
fork-ledger-d167724bac399178ef94180ea5cc297539fefe05.zip
Updated the pre-commit hook
Now it regenerates the build environment if Makefile.am or configure.ac has changed.
Diffstat (limited to 'tools/pre-commit')
-rwxr-xr-xtools/pre-commit31
1 files changed, 25 insertions, 6 deletions
diff --git a/tools/pre-commit b/tools/pre-commit
index 32fc7b9e..b1a3a187 100755
--- a/tools/pre-commit
+++ b/tools/pre-commit
@@ -1,29 +1,45 @@
#!/bin/sh
-set -e
+if [ ! $(git rev-parse --symbolic-full-name HEAD) = refs/heads/master ]; then
+ exit 0
+fi
+# These are the locations I keep my temporary source and build trees in
TMPDIR=$HOME/Products/ledger-pre-commit
MIRROR=$HOME/Products/ledger-pre-commit-mirror
-# Checkout a copy of the current index into TMPDIR
+# 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 which are no longer present in the index
+# 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 over changes, ignoring timestamps
+# 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 -rlpgoDO --size-only --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.
+# everything manually. If the user doesn't have acprep or myacprep, look for
+# other common autoconf-related script files.
if [ ! -f Makefile -o \
+ \( Makefile.am -nt Makefile -o \
+ configure.ac -nt Makefile \) -o \
\( -f tools/myacprep -a -f acprep -a \
- \( tools/myacprep -nt Makefile -o acprep -nt Makefile \) \) ]
+ \( tools/myacprep -nt Makefile -o \
+ acprep -nt Makefile \) \) ]
then
if [ -f tools/myacprep ]; then
tools/myacprep --local
@@ -36,4 +52,7 @@ then
fi
fi
+# Finally, (re)build this proposed source tree and see if it passes muster.
nice -n 20 make check
+
+exit 0