#!/bin/bash

rm -rf submit
mkdir submit

git archive --format=tar --prefix=icfp08/ HEAD | gzip > submit/icfp08.tgz

tar -C submit -xzf submit/icfp08.tgz

status=0

if test '!(-s submit/icfp08/team)'; then
	echo 'WARNING: You must add your team name to the team file.'
	status=1
fi

if test '!(-s submit/icfp08/contact)'; then
	echo 'WARNING: You must add names and contact details to the contact file.'
	status=1
fi

if grep -q -F 'This file should be edited' submit/icfp08/src/README; then
	echo 'WARNING: The src/README file should be edited to contain information about your code.'
	status=1
fi

non_comments=`grep -c '^[^#]' submit/icfp08/bin/run`
if test "$non_comments" -eq 0 ; then
	echo 'WARNING: There are no non-comment lines in the run script. It will not do anything!'
	status=1
fi

non_comments=`grep -c '^[^#]' submit/icfp08/bin/install`
if test "$non_comments" -eq 0 ; then
	echo 'NOTE: There are no installation actions for your script'
fi

exit $status