Archive for May, 2007
How to quickly lint PHP files in an upcoming svn commit
by maggie on May.15, 2007, under entry
Nothing more embarassing than committing awesome code with a parse error. Quick
php -l
will take care of that. But if your repository has files under many directories and you’ve made changes to many files, it can be a pain to php -l all of them as you can only pass one file to “php -l” at a time.
Here’s a quick shortcut:
svn stat | grep ‘php’ | awk ‘{print “php -l ” $2}’ | sh
“svn stat” will list all files that have been changed. The grep will filter the result and only show PHP files. The awk command takes the 2nd column of the output and does “php -l” on every file in that column.
Granted, this is convenient but painful to type and error prone. Solution: save it in a file svnlint.sh, then add an alias:
alias svnlint=’sh ~/svnlint.sh’
At this point, before every:
svn commit
do:
svnlint
Your PHP files will be free of syntax errors (so you can focus on those “real” bugs…)
Chocolate Covered SQL
by maggie on May.15, 2007, under entry
Mhm… chocolatey SQL…
