Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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.3.5' | 9 __version__ = '1.3.5' |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 # Statement seems to have no effect | 44 # Statement seems to have no effect |
| 45 # pylint: disable=W0104 | 45 # pylint: disable=W0104 |
| 46 json.loads | 46 json.loads |
| 47 except (ImportError, AttributeError): | 47 except (ImportError, AttributeError): |
| 48 # Import the one included in depot_tools. | 48 # Import the one included in depot_tools. |
| 49 sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) | 49 sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) |
| 50 import simplejson as json | 50 import simplejson as json |
| 51 | 51 |
| 52 # Local imports. | 52 # Local imports. |
| 53 import gclient_utils | 53 import gclient_utils |
| 54 import owners | |
| 54 import presubmit_canned_checks | 55 import presubmit_canned_checks |
| 55 import scm | 56 import scm |
| 56 | 57 |
| 57 | 58 |
| 58 # Ask for feedback only once in program lifetime. | 59 # Ask for feedback only once in program lifetime. |
| 59 _ASKED_FOR_FEEDBACK = False | 60 _ASKED_FOR_FEEDBACK = False |
| 60 | 61 |
| 61 | 62 |
| 62 class NotImplementedException(Exception): | 63 class NotImplementedException(Exception): |
| 63 """We're leaving placeholders in a bunch of places to remind us of the | 64 """We're leaving placeholders in a bunch of places to remind us of the |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 249 |
| 249 # InputApi.platform is the platform you're currently running on. | 250 # InputApi.platform is the platform you're currently running on. |
| 250 self.platform = sys.platform | 251 self.platform = sys.platform |
| 251 | 252 |
| 252 # The local path of the currently-being-processed presubmit script. | 253 # The local path of the currently-being-processed presubmit script. |
| 253 self._current_presubmit_path = os.path.dirname(presubmit_path) | 254 self._current_presubmit_path = os.path.dirname(presubmit_path) |
| 254 | 255 |
| 255 # We carry the canned checks so presubmit scripts can easily use them. | 256 # We carry the canned checks so presubmit scripts can easily use them. |
| 256 self.canned_checks = presubmit_canned_checks | 257 self.canned_checks = presubmit_canned_checks |
| 257 | 258 |
| 259 # TODO(dpranke): figure out a list of all approved owners for a repo | |
|
M-A Ruel
2011/02/24 16:25:57
I think owners are to respect to a specific Change
| |
| 260 # in order to be able to handle wildcard OWNERS files? | |
| 261 self.owners_db = owners.Database(change.RepositoryRoot(), | |
| 262 all_owners=None, open=open, os_path=self.os_path) | |
| 263 | |
| 258 def PresubmitLocalPath(self): | 264 def PresubmitLocalPath(self): |
| 259 """Returns the local path of the presubmit script currently being run. | 265 """Returns the local path of the presubmit script currently being run. |
| 260 | 266 |
| 261 This is useful if you don't want to hard-code absolute paths in the | 267 This is useful if you don't want to hard-code absolute paths in the |
| 262 presubmit script. For example, It can be used to find another file | 268 presubmit script. For example, It can be used to find another file |
| 263 relative to the PRESUBMIT.py script, so the whole tree can be branched and | 269 relative to the PRESUBMIT.py script, so the whole tree can be branched and |
| 264 the presubmit script still works, without editing its content. | 270 the presubmit script still works, without editing its content. |
| 265 """ | 271 """ |
| 266 return self._current_presubmit_path | 272 return self._current_presubmit_path |
| 267 | 273 |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 options.commit, | 1164 options.commit, |
| 1159 options.verbose, | 1165 options.verbose, |
| 1160 sys.stdout, | 1166 sys.stdout, |
| 1161 sys.stdin, | 1167 sys.stdin, |
| 1162 options.default_presubmit, | 1168 options.default_presubmit, |
| 1163 options.may_prompt) | 1169 options.may_prompt) |
| 1164 | 1170 |
| 1165 | 1171 |
| 1166 if __name__ == '__main__': | 1172 if __name__ == '__main__': |
| 1167 sys.exit(Main(sys.argv)) | 1173 sys.exit(Main(sys.argv)) |
| OLD | NEW |