Skip to content

Instantly share code, notes, and snippets.

@lsolesen
Created December 10, 2010 18:37
Show Gist options
  • Save lsolesen/736584 to your computer and use it in GitHub Desktop.
Save lsolesen/736584 to your computer and use it in GitHub Desktop.
checking for svn update. if updated run unit test
#!/usr/bin/env bash
# Note the use of env. This is because executables may not be placed in the same place on all systems. Notoriously, bsd (and thus mac osx) differs from linux. However, /usr/bin/env always exists in the same place, and it can tell you where other executables are. Thus, the above is good style for portability.
# Convention is to put variables in uppercase in shell script. The $() syntax is generally more readable
# You can embed a variable in a string, using the ${VAR_NAME} syntax
LOCAL_VERSION=$(svn info /var/www/project |grep Revision: |cut -c11-)
HEAD_VERSION=$(svn info /var/www/project -r 'HEAD' |grep Revision: |cut -c11-)
if [ ${LOCAL_VERSION} != ${{HEAD_VERSION} ]; then
svn up /var/www/project > /dev/null
phpunit /var/www/project/tests > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment