OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
7 """ | 7 """ |
8 | 8 |
9 __version__ = '1.6.1' | 9 __version__ = '1.6.1' |
10 | 10 |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1214 parser.add_option("--description", default='') | 1214 parser.add_option("--description", default='') |
1215 parser.add_option("--issue", type='int', default=0) | 1215 parser.add_option("--issue", type='int', default=0) |
1216 parser.add_option("--patchset", type='int', default=0) | 1216 parser.add_option("--patchset", type='int', default=0) |
1217 parser.add_option("--root", default=os.getcwd(), | 1217 parser.add_option("--root", default=os.getcwd(), |
1218 help="Search for PRESUBMIT.py up to this directory. " | 1218 help="Search for PRESUBMIT.py up to this directory. " |
1219 "If inherit-review-settings-ok is present in this " | 1219 "If inherit-review-settings-ok is present in this " |
1220 "directory, parent directories up to the root file " | 1220 "directory, parent directories up to the root file " |
1221 "system directories will also be searched.") | 1221 "system directories will also be searched.") |
1222 parser.add_option("--default_presubmit") | 1222 parser.add_option("--default_presubmit") |
1223 parser.add_option("--may_prompt", action='store_true', default=False) | 1223 parser.add_option("--may_prompt", action='store_true', default=False) |
1224 parser.add_option("--skip_canned", action='append', default=[], | |
1225 help="A list of checks to skip which appear in " | |
1226 "presubmit_canned_checks. Can be provided multiple times " | |
1227 "to skip multiple canned checks.") | |
1224 parser.add_option("--rietveld_url", help=optparse.SUPPRESS_HELP) | 1228 parser.add_option("--rietveld_url", help=optparse.SUPPRESS_HELP) |
1225 parser.add_option("--rietveld_email", help=optparse.SUPPRESS_HELP) | 1229 parser.add_option("--rietveld_email", help=optparse.SUPPRESS_HELP) |
1226 parser.add_option("--rietveld_password", help=optparse.SUPPRESS_HELP) | 1230 parser.add_option("--rietveld_password", help=optparse.SUPPRESS_HELP) |
1227 options, args = parser.parse_args(argv) | 1231 options, args = parser.parse_args(argv) |
1228 if options.verbose >= 2: | 1232 if options.verbose >= 2: |
1229 logging.basicConfig(level=logging.DEBUG) | 1233 logging.basicConfig(level=logging.DEBUG) |
1230 elif options.verbose: | 1234 elif options.verbose: |
1231 logging.basicConfig(level=logging.INFO) | 1235 logging.basicConfig(level=logging.INFO) |
1232 else: | 1236 else: |
1233 logging.basicConfig(level=logging.ERROR) | 1237 logging.basicConfig(level=logging.ERROR) |
1234 change_class, files = load_files(options, args) | 1238 change_class, files = load_files(options, args) |
1235 if not change_class: | 1239 if not change_class: |
1236 parser.error('For unversioned directory, <files> is not optional.') | 1240 parser.error('For unversioned directory, <files> is not optional.') |
1237 logging.info('Found %d file(s).' % len(files)) | 1241 logging.info('Found %d file(s).' % len(files)) |
1238 rietveld_obj = None | 1242 rietveld_obj = None |
1239 if options.rietveld_url: | 1243 if options.rietveld_url: |
1240 rietveld_obj = rietveld.CachingRietveld( | 1244 rietveld_obj = rietveld.CachingRietveld( |
1241 options.rietveld_url, | 1245 options.rietveld_url, |
1242 options.rietveld_email, | 1246 options.rietveld_email, |
1243 options.rietveld_password) | 1247 options.rietveld_password) |
1248 for method_name in options.skip_canned: | |
M-A Ruel
2013/03/07 15:50:33
I'd like you to restore them after.
missing = [m
| |
1249 if hasattr(presubmit_canned_checks, method_name): | |
1250 setattr(presubmit_canned_checks, method_name, lambda *_a, **_kw: []) | |
1251 else: | |
1252 parser.error('Attempted to skip nonexistent canned presubmit check: %s' | |
1253 % method_name) | |
1244 try: | 1254 try: |
1245 results = DoPresubmitChecks( | 1255 results = DoPresubmitChecks( |
1246 change_class(options.name, | 1256 change_class(options.name, |
1247 options.description, | 1257 options.description, |
1248 options.root, | 1258 options.root, |
1249 files, | 1259 files, |
1250 options.issue, | 1260 options.issue, |
1251 options.patchset, | 1261 options.patchset, |
1252 options.author), | 1262 options.author), |
1253 options.commit, | 1263 options.commit, |
1254 options.verbose, | 1264 options.verbose, |
1255 sys.stdout, | 1265 sys.stdout, |
1256 sys.stdin, | 1266 sys.stdin, |
1257 options.default_presubmit, | 1267 options.default_presubmit, |
1258 options.may_prompt, | 1268 options.may_prompt, |
1259 rietveld_obj) | 1269 rietveld_obj) |
1260 return not results.should_continue() | 1270 return not results.should_continue() |
1261 except PresubmitFailure, e: | 1271 except PresubmitFailure, e: |
1262 print >> sys.stderr, e | 1272 print >> sys.stderr, e |
1263 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1273 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
1264 print >> sys.stderr, 'If all fails, contact maruel@' | 1274 print >> sys.stderr, 'If all fails, contact maruel@' |
1265 return 2 | 1275 return 2 |
1266 | 1276 |
1267 | 1277 |
1268 if __name__ == '__main__': | 1278 if __name__ == '__main__': |
1269 fix_encoding.fix_encoding() | 1279 fix_encoding.fix_encoding() |
1270 sys.exit(Main(None)) | 1280 sys.exit(Main(None)) |
OLD | NEW |