I am writing a pre-commit hook script in perl. One of the requirement is that 
all files (luckly they are all text files) have the svn:eol-style property set 
to LF and the actual eol is indeed LF. If that's not the case I will reject the 
commit and direct the user to a page on our intranet to explain what to do to 
fix it.

My problem is how to detect whether the eol is LF and nothing else. I'm 
developing on Linux (Centos 5) and Perl 5.10. Subversion is 1.6.9, if it 
matters.

I thought about using the dos2unix utility (we only use Windows or Linux) and 
then check that the file hasn't changed, but it seems a lot of processing.

My second idea was to use a regular expression to check each line of each file. 
This way at least I would stop as soon as I find an eol that is not LF, saving 
some processing. I still need to svn cat each file into an array I think.

I know this is a common requirement but I don't know whether anyone has already 
done it in Perl. I would be greatful for any comment or suggestions of course.

Giulio


Linedata Limited
Registered Office: 85 Gracechurch St., London, EC3V 0AA
Registered in England and Wales No 3475006 VAT Reg No 710 3140 03




Reply via email to