| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 # TBD | 231 # TBD |
| 232 self.host_url = 'http://codereview.chromium.org' | 232 self.host_url = 'http://codereview.chromium.org' |
| 233 if self.rietveld: | 233 if self.rietveld: |
| 234 self.host_url = self.rietveld.url | 234 self.host_url = self.rietveld.url |
| 235 | 235 |
| 236 # We expose various modules and functions as attributes of the input_api | 236 # We expose various modules and functions as attributes of the input_api |
| 237 # so that presubmit scripts don't have to import them. | 237 # so that presubmit scripts don't have to import them. |
| 238 self.basename = os.path.basename | 238 self.basename = os.path.basename |
| 239 self.cPickle = cPickle | 239 self.cPickle = cPickle |
| 240 self.cStringIO = cStringIO | 240 self.cStringIO = cStringIO |
| 241 self.glob = glob.glob |
| 241 self.json = json | 242 self.json = json |
| 242 self.logging = logging.getLogger('PRESUBMIT') | 243 self.logging = logging.getLogger('PRESUBMIT') |
| 243 self.os_listdir = os.listdir | 244 self.os_listdir = os.listdir |
| 244 self.os_walk = os.walk | 245 self.os_walk = os.walk |
| 245 self.os_path = os.path | 246 self.os_path = os.path |
| 246 self.pickle = pickle | 247 self.pickle = pickle |
| 247 self.marshal = marshal | 248 self.marshal = marshal |
| 248 self.re = re | 249 self.re = re |
| 249 self.subprocess = subprocess | 250 self.subprocess = subprocess |
| 250 self.tempfile = tempfile | 251 self.tempfile = tempfile |
| (...skipping 11 matching lines...) Expand all Loading... |
| 262 | 263 |
| 263 # The local path of the currently-being-processed presubmit script. | 264 # The local path of the currently-being-processed presubmit script. |
| 264 self._current_presubmit_path = os.path.dirname(presubmit_path) | 265 self._current_presubmit_path = os.path.dirname(presubmit_path) |
| 265 | 266 |
| 266 # We carry the canned checks so presubmit scripts can easily use them. | 267 # We carry the canned checks so presubmit scripts can easily use them. |
| 267 self.canned_checks = presubmit_canned_checks | 268 self.canned_checks = presubmit_canned_checks |
| 268 | 269 |
| 269 # TODO(dpranke): figure out a list of all approved owners for a repo | 270 # TODO(dpranke): figure out a list of all approved owners for a repo |
| 270 # in order to be able to handle wildcard OWNERS files? | 271 # in order to be able to handle wildcard OWNERS files? |
| 271 self.owners_db = owners.Database(change.RepositoryRoot(), | 272 self.owners_db = owners.Database(change.RepositoryRoot(), |
| 272 fopen=file, os_path=self.os_path) | 273 fopen=file, os_path=self.os_path, glob=self.glob) |
| 273 self.verbose = verbose | 274 self.verbose = verbose |
| 274 | 275 |
| 275 def PresubmitLocalPath(self): | 276 def PresubmitLocalPath(self): |
| 276 """Returns the local path of the presubmit script currently being run. | 277 """Returns the local path of the presubmit script currently being run. |
| 277 | 278 |
| 278 This is useful if you don't want to hard-code absolute paths in the | 279 This is useful if you don't want to hard-code absolute paths in the |
| 279 presubmit script. For example, It can be used to find another file | 280 presubmit script. For example, It can be used to find another file |
| 280 relative to the PRESUBMIT.py script, so the whole tree can be branched and | 281 relative to the PRESUBMIT.py script, so the whole tree can be branched and |
| 281 the presubmit script still works, without editing its content. | 282 the presubmit script still works, without editing its content. |
| 282 """ | 283 """ |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 except PresubmitFailure, e: | 1261 except PresubmitFailure, e: |
| 1261 print >> sys.stderr, e | 1262 print >> sys.stderr, e |
| 1262 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1263 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
| 1263 print >> sys.stderr, 'If all fails, contact maruel@' | 1264 print >> sys.stderr, 'If all fails, contact maruel@' |
| 1264 return 2 | 1265 return 2 |
| 1265 | 1266 |
| 1266 | 1267 |
| 1267 if __name__ == '__main__': | 1268 if __name__ == '__main__': |
| 1268 fix_encoding.fix_encoding() | 1269 fix_encoding.fix_encoding() |
| 1269 sys.exit(Main(None)) | 1270 sys.exit(Main(None)) |
| OLD | NEW |