summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-23 21:24:05 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-23 21:24:05 +0000
commitb337cb5b37425474f1caf185acd159b9dc5436c7 (patch)
treec39cf7fc8bd6f6318d8766fe19547cd4b8a632b7 /PRESUBMIT.py
parentadb2f3d15ea878991ff987e4d4740605f5e1417f (diff)
downloadchromium_src-b337cb5b37425474f1caf185acd159b9dc5436c7.zip
chromium_src-b337cb5b37425474f1caf185acd159b9dc5436c7.tar.gz
chromium_src-b337cb5b37425474f1caf185acd159b9dc5436c7.tar.bz2
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
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r--PRESUBMIT.py44
1 files changed, 44 insertions, 0 deletions
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