From b337cb5b37425474f1caf185acd159b9dc5436c7 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Sun, 23 Jan 2011 21:24:05 +0000 Subject: Add a new presubmit check to enforce automatic svn properties in svn config. This should help simplifying project maintenance. BUG=none TEST=none Review URL: http://codereview.chromium.org/6241012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72305 0039d316-1c4b-4281-b951-d872f2087c98 --- PRESUBMIT.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'PRESUBMIT.py') diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 65df224..ffb668c 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -68,6 +68,49 @@ def _CheckSingletonInHeaders(input_api, output_api, source_file_filter): files) ] return [] + +def _CheckSubversionConfig(input_api, output_api): + """Verifies the subversion config file is correctly setup. + + Checks that autoprops are enabled, returns an error otherwise. + """ + join = input_api.os_path.join + if input_api.platform == 'win32': + appdata = input_api.environ.get('APPDATA', '') + if not appdata: + return [output_api.PresubmitError('%APPDATA% is not configured.')] + path = join(appdata, 'Subversion', 'config') + else: + home = input_api.environ.get('HOME', '') + if not home: + return [output_api.PresubmitError('$HOME is not configured.')] + path = join(home, '.subversion', 'config') + + error_msg = ( + 'Please look at http://dev.chromium.org/developers/coding-style to\n' + 'configure your subversion configuration file. This enables automatic\n' + 'properties to simplify the project maintenance.') + + try: + lines = open(path, 'r').read().splitlines() + # Make sure auto-props is enabled and check for 2 Chromium standard + # auto-prop. + if (not '*.cc = svn:eol-style=LF' in lines or + not '*.pdf = svn:mime-type=application/pdf' in lines or + not 'enable-auto-props = yes' in lines): + return [ + output_api.PresubmitError( + 'It looks like you have not configured your subversion config ' + 'file.\n' + error_msg) + ] + except (OSError, IOError): + return [ + output_api.PresubmitError( + 'Can\'t find your subversion config file.\n' + error_msg) + ] + return [] + + def _CheckConstNSObject(input_api, output_api, source_file_filter): """Checks to make sure no objective-c files have |const NSSomeClass*|.""" pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') @@ -172,6 +215,7 @@ def CheckChangeOnCommit(input_api, output_api): input_api, output_api)) results.extend(input_api.canned_checks.CheckChangeHasTestField( input_api, output_api)) + results.extend(_CheckSubversionConfig(input_api, output_api)) return results -- cgit v1.1