Skip to content

Commit

Permalink
pre-commit hook no longer generates patch; it fails if patch.ips is o…
Browse files Browse the repository at this point in the history
…ut of date.
  • Loading branch information
nstbayless committed Aug 27, 2017
1 parent bf662f9 commit 0bc46ca
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
base.nes
working.nes
edit.nes
.patch-prev.ips
27 changes: 22 additions & 5 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,29 @@ then
fi

# generate patch
./make-patch.sh
./make-patch.sh .patch-prev.ips

# pause to read input if successful:
if [ $? -eq 0 ]
if [ ! $? -eq 0 ]
then
sleep 0.5
chmod +wrx .patch-prev.ips
rm .patch-prev.ips
exit 2;
fi

exit $?
test=`diff patch.ips .patch-prev.ips`

chmod +wrx .patch-prev.ips
rm .patch-prev.ips

if [ ! -z test ]
then
echo "Cannot commit while patch.ips is not up-to-date!"
echo "(Either run ./apply.sh to bring patch.ips up to date, or commit again with --no-verify)"
exit 1;
fi

# pause to read input if successful:
sleep 0.5

exit 0

17 changes: 11 additions & 6 deletions make-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

# find flips patcher:
flips="./flips/flips.exe"
outdir="patch.ips"
if [ $# -eq 1 ]
then
outdir="$1"
fi

if [ "$op" = "Linux" ]
then
Expand All @@ -15,16 +20,16 @@ then
exit 2;
fi

echo "Generating patch.ips..."
echo "Generating $outdir..."

chmod u+w patch.ips
chmod u+w $outdir 2>/dev/null

rm patch.ips
rm $outdir 2>/dev/null

$flips --create --ips base.nes working.nes patch.ips
$flips --create --ips base.nes working.nes $outdir
err=$?

chmod u+r patch.ips
chmod a-wx patch.ips
chmod u+r $outdir
chmod a-wx $outdir

exit $?

0 comments on commit 0bc46ca

Please sign in to comment.