Detecting CR eol
From: Giulio Troccoli <Giulio.Troccoli_at_uk.linedata.com>
Date: Wed, 8 Sep 2010 09:25:38 +0100
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
|
This is an archived mail posted to the Subversion Users mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.