I use a script like the following to fix trailing whitespace when I get errors (I pipe the output of gcl presubmit to it). You can easily extend it to fix bad line-endings (it will already ensure all touched files use \n) and it should be straightforward to extend it to do the propset stuff as well.
Cheers, Jói import re import sys output = sys.stdin.read() filenames = [] # First find trailing whitespace concerns as per Chrome's presubmit. rex = re.compile( r'.+Found line ending with white spaces in[^*]+\*+\s+([^*]+)\*+.*', re.M | re.S) result = rex.match(output) if result: block = result.group(1) filenames.extend(re.findall('(.+?), line [0-9]+', block)) if not filenames: print "Found no problem files" done_processing = {} for filename in filenames: if filename in done_processing: print "Already processed %s" % filename continue done_processing[filename] = 1 f = open(filename, 'rb') lines = f.readlines() f.close() f = open(filename, 'wb') for line in lines: line = line.rstrip() f.write(line) f.write('\n') f.close() print "Finished processing %s" % filename On Wed, Nov 18, 2009 at 4:32 PM, Marc-Antoine Ruel <mar...@chromium.org> wrote: > First, I'd prefer to keep the presubmit checks from having any side-effect. > > For a) > You haven't mentioned which editor you use but if it is a problem for > you, maybe you should tweak the editor? VS, emacs, vim can be modified > to do it or at least highlight it; I don't know about xcode. Otherwise > a very simple python script can do it for you, maybe you could create > a new kind of gcl hook. git already has functionality for commit > hooks. > > For b), follow the steps at > http://dev.chromium.org/developers/coding-style#TOC-Subversion-properties > It's necessary for git usage too. > > M-A > > On Wed, Nov 18, 2009 at 4:26 PM, Dave MacLachlan <dmacl...@google.com> wrote: >> Hey Marc-Antoine: >> >> What would it take to have the presubmit scripts automagically do the >> following: >> >> a) Remove all whitespace at the end of .h, .c, .cc and .mm files? >> b) Apply 'svn pset svn:eol-style LF' as necessary to .h, .c, .cc and .mm >> files? >> >> This would save me a great deal of time. My editor of choice does not take >> care of getting rid of the whitespace for me. >> >> Cheers, >> Dave >> > > -- > Chromium Developers mailing list: chromium-dev@googlegroups.com > View archives, change email options, or unsubscribe: > http://groups.google.com/group/chromium-dev > -- Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev