summaryrefslogtreecommitdiff
path: root/tools/pre-commit
blob: 32fc7b9e783d29630ba38f33222ae7a1b620d49f (plain)
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
38
39
#!/bin/sh

set -e

TMPDIR=$HOME/Products/ledger-pre-commit
MIRROR=$HOME/Products/ledger-pre-commit-mirror

# Checkout a copy of the current index into TMPDIR
git checkout-index --prefix=$MIRROR/ -af

# Remove files 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
rsync -rlpgoDO --size-only --delete \
    --exclude-from=tools/excludes $MIRROR/ $TMPDIR/

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 [ ! -f Makefile -o \
     \( -f tools/myacprep -a -f acprep -a \
     \( tools/myacprep -nt Makefile -o acprep -nt Makefile \) \) ]
then
    if [ -f tools/myacprep ]; then
	tools/myacprep --local
    elif [ -f acprep ]; then
	./acprep --local
    elif [ -f autogen.sh ]; then
	sh autogen.sh && ./configure
    else
	autoreconf && ./configure
    fi
fi

nice -n 20 make check