How can a little cron, bash + make based script (e.g. much smaller and less robust than, for example, Hudson) build-bot poll a git repo and detect if it should build now – e.g. if in its periodic pull from the remote git repo, it has retrieved new code?
Currently, it looks like this:
git fetch > build_log.txt 2>&1
if [ $? -eq 0 ]
then
echo "Fetch from git done";
git merge FETCH_HEAD >> build_log.txt 2>&1 ;
if [ $? -eq 0 ]
then
echo "Merge via git done"; ...
# builds unconditionally at the moment
fi
fi
If nothing was fetched, then “get fetch” will output no lines, so just check for zero filesize on build_log.txt: