summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-04-28 12:33:10 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-04-28 12:33:10 +0000
commitf23b51aaa0dff06c7926e803b0f09103c60147a4 (patch)
treeb114d16dcefb3fb12f90ef0d9d3273d5c5f425b7
parent2c682e6192b86eccaa869c23d82cde81b4ea42d4 (diff)
parentb72a94ff1b31952577815839e91e410a8384d981 (diff)
downloadmorph-f23b51aaa0dff06c7926e803b0f09103c60147a4.tar.gz
Merge branch 'baserock/richardipsum/improve_copyright_check'
Reviewed by: Daniel Silverstone Richard Maw
-rwxr-xr-xcheck8
-rwxr-xr-xscripts/check-copyright-year18
2 files changed, 11 insertions, 15 deletions
diff --git a/check b/check
index 77d4e826..82774119 100755
--- a/check
+++ b/check
@@ -92,13 +92,12 @@ export PYTHONPATH
# Run the style checks
-errors=0
if "$run_style" && [ -d .git ];
then
echo "Checking copyright statements"
if ! (git ls-files --cached -z |
xargs -0r scripts/check-copyright-year); then
- errors=1
+ exit 1
fi
echo 'Checking source code for silliness'
@@ -107,12 +106,9 @@ then
grep -Ev 'tests[^/]*/.*\.std(out|err)' |
grep -vF 'tests.build/build-system-autotools.script' |
xargs -r scripts/check-silliness); then
- errors=1
+ exit 1
fi
fi
-if [ "$errors" != 0 ]; then
- exit "$errors"
-fi
# Clean up artifacts from previous (possibly failed) runs, build,
# and run the tests.
diff --git a/scripts/check-copyright-year b/scripts/check-copyright-year
index d72ddbc6..e72eaeea 100755
--- a/scripts/check-copyright-year
+++ b/scripts/check-copyright-year
@@ -17,13 +17,14 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+from __future__ import print_function
import datetime
import re
+import sys
import cliapp
-
class CheckCopyrightYear(cliapp.Application):
pat = re.compile(r'^[ #/*]*Copyright\s+(\(C\)\s*)'
@@ -39,7 +40,8 @@ class CheckCopyrightYear(cliapp.Application):
def cleanup(self):
if not self.all_ok:
- raise cliapp.AppException('Some copyright years need fixing')
+ print('ERROR: Some copyright years need fixing', file=sys.stderr)
+ sys.exit(1)
def get_uncommitted_files(self):
filenames = set()
@@ -73,14 +75,12 @@ class CheckCopyrightYear(cliapp.Application):
if start <= year <= end:
ok = True
- if self.settings['verbose']:
- if ok:
+ if ok:
+ if self.settings['verbose']:
self.output.write('OK %s\n' % filename)
- else:
- self.output.write('BAD %s:%s:%s\n' %
- (filename, self.lineno, line.strip()))
- elif not ok:
- self.output.write('%s\n' % filename)
+ else:
+ self.output.write('BAD %s:%s:%s\n' %
+ (filename, self.lineno, line.strip()))
self.all_ok = self.all_ok and ok