16

I have an svn server that I checkout the repository in my computer.

The main repositiry has about 2k files

  • 3rd party
  • generic code classes
  • custom classes

I have made changes to lots of files (mainly php) and I want to make sure they are all valid before I commit.

svn commit -m "i fix the bug #293"

How can I check all the files at once to make sure they are valid and no php errors so I dont have to manually check all these files.

Zoe
  • 27,060
  • 21
  • 118
  • 148
aki
  • 1,241
  • 2
  • 13
  • 43
  • 3
    Do you mean you modified the code without being able to run it on your developer machine? Bad practice.... – Bas Slagter Nov 21 '11 at 13:48
  • 7
    Run your [Unit Tests](http://stackoverflow.com/questions/1383/what-is-unit-testing) before commiting. – Gordon Nov 21 '11 at 13:48

1 Answers1

27

This bash oneliner will the modified php files and filter the ones that have no syntax errors:

for i in $(svn status | grep -v ^? | grep php | awk '{print $2}') ; do php -l $i ; done | grep 'Parse error'
Maerlyn
  • 33,687
  • 18
  • 94
  • 85
  • 2
    `for i in $(svn status|grep -v ^?|grep php|awk '{print $2}') ; do php -l $i ; done | grep 'Parse error'` – jmz Nov 21 '11 at 14:01