Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: PRESUBMIT.py

Issue 6241012: Add a new presubmit check to enforce automatic svn properties in svn config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only run the check on commit, we don't care on upload Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 65df2245acad080469ceb9c7202cc7a4c2bac924..ffb668cd1e9bed5aa9beebabf853f7b5cb68e661 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)
wtc 2011/01/31 22:37:36 I got this error message when I tried to commit a
+ ]
+ 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698