From: Brian Warner Date: Mon, 29 Jun 2009 22:46:58 +0000 (-0700) Subject: * find-trailing-spaces.py: exit rc=1 if whitespace found, to be a pre-commit hook X-Git-Tag: trac-4000~52 X-Git-Url: https://git.rkrishnan.org/components/provisioning?a=commitdiff_plain;h=5626e17725ccf941d1f2d3d4d45bdc150aa94559;p=tahoe-lafs%2Ftahoe-lafs.git * find-trailing-spaces.py: exit rc=1 if whitespace found, to be a pre-commit hook --- diff --git a/misc/find-trailing-spaces.py b/misc/find-trailing-spaces.py index a1313216..ad2cc583 100644 --- a/misc/find-trailing-spaces.py +++ b/misc/find-trailing-spaces.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import os +import os, sys from twisted.python import usage @@ -11,6 +11,8 @@ class Options(usage.Options): def parseArgs(self, *starting_points): self.starting_points = starting_points +found = [False] + def check(fn): f = open(fn, "r") for i,line in enumerate(f.readlines()): @@ -21,6 +23,7 @@ def check(fn): if line.rstrip() != line: # the %s:%d:%d: lets emacs' compile-mode jump to those locations print "%s:%d:%d: trailing whitespace" % (fn, i+1, len(line)+1) + found[0] = True f.close() o = Options() @@ -34,3 +37,6 @@ if o['recursive']: else: for fn in o.starting_points: check(fn) +if found[0]: + sys.exit(1) +sys.exit(0)