OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 """Define the supported projects.""" | 4 """Define the supported projects.""" |
5 | 5 |
6 import json | 6 import json |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import re | 9 import re |
10 import sys | 10 import sys |
(...skipping 21 matching lines...) Expand all Loading... | |
32 INTERNAL_DIR = os.path.abspath( | 32 INTERNAL_DIR = os.path.abspath( |
33 os.path.join(ROOT_DIR, os.pardir, 'commit-queue-internal')) | 33 os.path.join(ROOT_DIR, os.pardir, 'commit-queue-internal')) |
34 | 34 |
35 # These come from commit-queue in the internal repo. | 35 # These come from commit-queue in the internal repo. |
36 if os.path.isdir(INTERNAL_DIR): | 36 if os.path.isdir(INTERNAL_DIR): |
37 sys.path.insert(0, INTERNAL_DIR) | 37 sys.path.insert(0, INTERNAL_DIR) |
38 import chromium_committers # pylint: disable=F0401 | 38 import chromium_committers # pylint: disable=F0401 |
39 import gyp_committers # pylint: disable=F0401 | 39 import gyp_committers # pylint: disable=F0401 |
40 import nacl_committers # pylint: disable=F0401 | 40 import nacl_committers # pylint: disable=F0401 |
41 import skia_committers # pylint: disable=F0401 | 41 import skia_committers # pylint: disable=F0401 |
42 import projects_internal # pylint: disable=F0401 | |
Paweł Hajdan Jr.
2014/01/21 18:19:06
nit: Just 2 spaces between code and comment instea
| |
42 else: | 43 else: |
43 print >> sys.stderr, ( | 44 print >> sys.stderr, ( |
44 'Failed to find commit-queue-internal; will fail to start!') | 45 'Failed to find commit-queue-internal; will fail to start!') |
45 chromium_committers = None | 46 chromium_committers = None |
46 gyp_committers = None | 47 gyp_committers = None |
47 nacl_committers = None | 48 nacl_committers = None |
48 skia_committers = None | 49 skia_committers = None |
49 | 50 projects_internal = None |
50 | 51 |
51 # It's tricky here because 'chrome' is remapped to 'svn' on src.chromium.org but | 52 # It's tricky here because 'chrome' is remapped to 'svn' on src.chromium.org but |
52 # the other repositories keep their repository name. So don't list it here. | 53 # the other repositories keep their repository name. So don't list it here. |
53 SVN_HOST_ALIASES = [ | 54 SVN_HOST_ALIASES = [ |
54 'svn://svn.chromium.org', | 55 'svn://svn.chromium.org', |
55 'svn://chrome-svn', | 56 'svn://chrome-svn', |
56 'svn://chrome-svn.corp', | 57 'svn://chrome-svn.corp', |
57 'svn://chrome-svn.corp.google.com' | 58 'svn://chrome-svn.corp.google.com' |
58 ] | 59 ] |
59 | 60 |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
750 verifiers = [ | 751 verifiers = [ |
751 presubmit_check.PresubmitCheckVerifier(context_obj, timeout=900), | 752 presubmit_check.PresubmitCheckVerifier(context_obj, timeout=900), |
752 ] | 753 ] |
753 | 754 |
754 return pending_manager.PendingManager( | 755 return pending_manager.PendingManager( |
755 context_obj, | 756 context_obj, |
756 verifiers_no_patch, | 757 verifiers_no_patch, |
757 verifiers) | 758 verifiers) |
758 | 759 |
759 | 760 |
761 def _get_supported_projects(): | |
762 """Return project names and corresponding functions in a dict. | |
763 | |
764 Projects functions start with '_gen_' and are searched for in the present | |
765 file and in commit-queue-internal/projects_internal.py. | |
766 """ | |
767 projects = {} | |
768 for name in dir(sys.modules[__name__]): | |
769 if name.startswith('_gen_'): | |
770 projects[name[5:]] = getattr(sys.modules[__name__], name) | |
771 | |
772 if projects_internal is not None: | |
Paweł Hajdan Jr.
2014/01/21 18:19:06
nit: Why not just projects_internal? (remove the "
| |
773 for name in dir(sys.modules['projects_internal']): | |
774 if name.startswith('_gen_'): | |
775 if name[5:] in projects: | |
776 logging.warn('public project function %s overriden by private one' | |
Paweł Hajdan Jr.
2014/01/21 18:19:06
I'd like to make this stronger than just a warning
pgervais
2014/01/21 18:57:24
Because "internal" projects can also be used for t
Paweł Hajdan Jr.
2014/01/21 22:29:44
I find it dangerous enough to really avoid support
| |
777 % name) | |
778 projects[name[5:]] = getattr(sys.modules['projects_internal'], name) | |
779 | |
780 return projects | |
781 | |
782 | |
760 def supported_projects(): | 783 def supported_projects(): |
761 """List the projects that can be managed by the commit queue.""" | 784 """List the projects that can be managed by the commit queue.""" |
762 return sorted( | 785 return sorted(_get_supported_projects().keys()) |
763 x[5:] for x in dir(sys.modules[__name__]) if x.startswith('_gen_')) | |
764 | 786 |
765 | 787 |
766 def load_project(project, user, root_dir, rietveld_obj, no_try): | 788 def load_project(project, user, root_dir, rietveld_obj, no_try): |
767 """Loads the specified project.""" | 789 """Loads the specified project. |
790 | |
791 Args: | |
792 project (string): project name (suffix of _gen_* functions above) | |
793 user (string): email address identifying the commit bot. | |
794 root_dir (string): working directory (were credentials are stored e.g. .gaia) | |
795 rietveld_obj (rietveld.Rietveld): object for communicating with Rietveld. | |
796 no_try (boolean): is True, means "do not send try jobs" | |
797 """ | |
768 assert os.path.isabs(root_dir) | 798 assert os.path.isabs(root_dir) |
769 return getattr(sys.modules[__name__], '_gen_' + project)( | 799 return _get_supported_projects()[project]( |
770 user, root_dir, rietveld_obj, no_try) | 800 user, root_dir, rietveld_obj, no_try) |
801 | |
OLD | NEW |