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 | |
43 else: | 42 else: |
44 print >> sys.stderr, ( | 43 print >> sys.stderr, ( |
45 'Failed to find commit-queue-internal; will fail to start!') | 44 'Failed to find commit-queue-internal; will fail to start!') |
46 chromium_committers = None | 45 chromium_committers = None |
47 gyp_committers = None | 46 gyp_committers = None |
48 nacl_committers = None | 47 nacl_committers = None |
49 skia_committers = None | 48 skia_committers = None |
50 projects_internal = None | 49 |
51 | 50 |
52 # It's tricky here because 'chrome' is remapped to 'svn' on src.chromium.org but | 51 # It's tricky here because 'chrome' is remapped to 'svn' on src.chromium.org but |
53 # the other repositories keep their repository name. So don't list it here. | 52 # the other repositories keep their repository name. So don't list it here. |
54 SVN_HOST_ALIASES = [ | 53 SVN_HOST_ALIASES = [ |
55 'svn://svn.chromium.org', | 54 'svn://svn.chromium.org', |
56 'svn://chrome-svn', | 55 'svn://chrome-svn', |
57 'svn://chrome-svn.corp', | 56 'svn://chrome-svn.corp', |
58 'svn://chrome-svn.corp.google.com' | 57 'svn://chrome-svn.corp.google.com' |
59 ] | 58 ] |
60 | 59 |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 verifiers = [ | 752 verifiers = [ |
754 presubmit_check.PresubmitCheckVerifier(context_obj, timeout=900), | 753 presubmit_check.PresubmitCheckVerifier(context_obj, timeout=900), |
755 ] | 754 ] |
756 | 755 |
757 return pending_manager.PendingManager( | 756 return pending_manager.PendingManager( |
758 context_obj, | 757 context_obj, |
759 verifiers_no_patch, | 758 verifiers_no_patch, |
760 verifiers) | 759 verifiers) |
761 | 760 |
762 | 761 |
763 def _get_supported_projects(): | |
764 """Return project names and corresponding functions in a dict. | |
765 | |
766 Projects functions start with '_gen_' and are searched for in the present | |
767 file and in commit-queue-internal/projects_internal.py. | |
768 """ | |
769 projects = {} | |
770 for name in dir(sys.modules[__name__]): | |
771 if name.startswith('_gen_'): | |
772 projects[name[5:]] = getattr(sys.modules[__name__], name) | |
773 | |
774 if projects_internal: | |
775 for name in dir(sys.modules['projects_internal']): | |
776 if name.startswith('_gen_'): | |
777 if name[5:] in projects: | |
778 raise errors.ConfigurationError( | |
779 'public project function %s overriden by private one' | |
780 % name) | |
781 projects[name[5:]] = getattr(sys.modules['projects_internal'], name) | |
782 | |
783 return projects | |
784 | |
785 | |
786 def supported_projects(): | 762 def supported_projects(): |
787 """List the projects that can be managed by the commit queue.""" | 763 """List the projects that can be managed by the commit queue.""" |
788 return sorted(_get_supported_projects().keys()) | 764 return sorted( |
| 765 x[5:] for x in dir(sys.modules[__name__]) if x.startswith('_gen_')) |
789 | 766 |
790 | 767 |
791 def load_project(project, user, root_dir, rietveld_obj, no_try): | 768 def load_project(project, user, root_dir, rietveld_obj, no_try): |
792 """Loads the specified project. | 769 """Loads the specified project.""" |
793 | |
794 Args: | |
795 project (string): project name (suffix of _gen_* functions above) | |
796 user (string): email address identifying the commit bot. | |
797 root_dir (string): working directory (were credentials are stored e.g. .gaia) | |
798 rietveld_obj (rietveld.Rietveld): object for communicating with Rietveld. | |
799 no_try (boolean): is True, means "do not send try jobs" | |
800 """ | |
801 assert os.path.isabs(root_dir) | 770 assert os.path.isabs(root_dir) |
802 return _get_supported_projects()[project]( | 771 return getattr(sys.modules[__name__], '_gen_' + project)( |
803 user, root_dir, rietveld_obj, no_try) | 772 user, root_dir, rietveld_obj, no_try) |
804 | |
OLD | NEW |