[Zope3-dev] Re: [Zope-Coders] Denying commit for carriage returns in text

Fred L. Drake, Jr. fred@zope.com
Wed, 13 Nov 2002 18:26:03 -0500


Ken Manheimer writes:
 > 1. If we were to do this, i think we should limit the checks to python
 >    files only.  (We don't want to prevent people from checking in .bat
 >    files with CR line endings, do we?)

Er, yes.  They are text files, and the CVS client is supposed to
normalize those.

 >    I know that loginfo scripts are passed the directory name and then
 >    a funky single token of command separated fields which name the
 >    file, old version, and new version.  If commitinfo gets something
 >    similar, then it should be able to look for only .py files.

Yes, it does.  The first arg is the directory within the repository,
and remaining args are the (relative) names of the files.  The current
directory is a temp directory; copies of the new versions are located
there with their regular names.

 >    I'm a bit worried even if we restrict the checks to just python
 >    files, particularly since we'll all have forgotten this hack is in
 >    effect when it bites someone who needs CR line endings in their
 >    triple-quoted strings...

The message that gets printed can be made very clear, and can point to
a policy statement on zope.org.

 > 2. I think this is a simpler check for lines ending with carriage return:
 > 
 >    grep -q $(echo -en '\r')'$') file
 > 
 >    It exits with 0 if any found, 1 otherwise.

Yeah, but the Python version of script I just sent is even faster.  ;-)

 > I think these two bits should simplify the script a lot.  More
 > elaborate grep expressions (for tabs or whatever) would not
 > significantly increase the processing costs...

Again, the Python version is better than the shell version.


  -Fred

-- 
Fred L. Drake, Jr.  <fred at zope.com>
PythonLabs at Zope Corporation