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 |
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: |
| 773 for name in dir(sys.modules['projects_internal']): |
| 774 if name.startswith('_gen_'): |
| 775 if name[5:] in projects: |
| 776 raise errors.ConfigurationError( |
| 777 'public project function %s overriden by private one' |
| 778 % name) |
| 779 projects[name[5:]] = getattr(sys.modules['projects_internal'], name) |
| 780 |
| 781 return projects |
| 782 |
| 783 |
760 def supported_projects(): | 784 def supported_projects(): |
761 """List the projects that can be managed by the commit queue.""" | 785 """List the projects that can be managed by the commit queue.""" |
762 return sorted( | 786 return sorted(_get_supported_projects().keys()) |
763 x[5:] for x in dir(sys.modules[__name__]) if x.startswith('_gen_')) | |
764 | 787 |
765 | 788 |
766 def load_project(project, user, root_dir, rietveld_obj, no_try): | 789 def load_project(project, user, root_dir, rietveld_obj, no_try): |
767 """Loads the specified project.""" | 790 """Loads the specified project. |
| 791 |
| 792 Args: |
| 793 project (string): project name (suffix of _gen_* functions above) |
| 794 user (string): email address identifying the commit bot. |
| 795 root_dir (string): working directory (were credentials are stored e.g. .gaia) |
| 796 rietveld_obj (rietveld.Rietveld): object for communicating with Rietveld. |
| 797 no_try (boolean): is True, means "do not send try jobs" |
| 798 """ |
768 assert os.path.isabs(root_dir) | 799 assert os.path.isabs(root_dir) |
769 return getattr(sys.modules[__name__], '_gen_' + project)( | 800 return _get_supported_projects()[project]( |
770 user, root_dir, rietveld_obj, no_try) | 801 user, root_dir, rietveld_obj, no_try) |
| 802 |
OLD | NEW |