Maggie Nelson

databases and code goodness

3. Find x.

TAGS: None

Somehow math and smartasses tend to gravitate toward each other.


More: haha.nu.

  • Author: maggie
  • Published: May 15th, 2007
  • Category: entry
  • Comments: 5

How to quickly lint PHP files in an upcoming svn commit

TAGS: None

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

TAGS: None

Mhm… chocolatey SQL

© 2010 Maggie Nelson. All Rights Reserved.

This blog is powered by the Wordpress platform and beach rentals.