Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index caa9b604b2d54800f8b4d0a0ebc5851d91b930bf..acfb15433ef1bd2fe63caed15d38d9a533d82e41 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -214,6 +214,16 @@ def add_git_similarity(parser): |
| parser.parse_args = Parse |
| +def _get_properties_from_options(options): |
|
Michael Achenbach
2015/09/14 14:18:23
This is partially copied from https://code.google.
|
| + properties = dict(x.split('=', 1) for x in options.properties) |
| + for key, val in properties.iteritems(): |
| + try: |
| + properties[key] = json.loads(val) |
| + except ValueError: |
| + pass # If a value couldn't be evaluated, silently ignore it. |
|
tandrii(chromium)
2015/09/14 14:52:22
how about:
s/, silently ignore it./, treat it as a
Michael Achenbach
2015/09/15 08:32:57
Done.
|
| + return properties |
| + |
| + |
| def _prefix_master(master): |
| """Convert user-specified master name to full master name. |
| @@ -228,8 +238,7 @@ def _prefix_master(master): |
| return '%s%s' % (prefix, master) |
| -def trigger_try_jobs(auth_config, changelist, options, masters, category, |
| - override_properties=None): |
|
Michael Achenbach
2015/09/14 14:18:23
This was added by me a while ago in order to hook
tandrii(chromium)
2015/09/14 14:52:22
Acknowledged.
|
| +def trigger_try_jobs(auth_config, changelist, options, masters, category): |
| rietveld_url = settings.GetDefaultServerUrl() |
| rietveld_host = urlparse.urlparse(rietveld_url).hostname |
| authenticator = auth.get_authenticator_for_host(rietveld_host, auth_config) |
| @@ -238,6 +247,7 @@ def trigger_try_jobs(auth_config, changelist, options, masters, category, |
| issue_props = changelist.GetIssueProperties() |
| issue = changelist.GetIssue() |
| patchset = changelist.GetMostRecentPatchset() |
| + properties = _get_properties_from_options(options) |
| buildbucket_put_url = ( |
| 'https://{hostname}/_ah/api/buildbucket/v1/builds/batch'.format( |
| @@ -273,8 +283,8 @@ def trigger_try_jobs(auth_config, changelist, options, masters, category, |
| 'testfilter': tests, |
| }, |
| } |
| - if override_properties: |
| - parameters['properties'].update(override_properties) |
| + if properties: |
| + parameters['properties'].update(properties) |
|
tandrii(chromium)
2015/09/14 14:52:22
I'm not sure if overriding all properties is a goo
Michael Achenbach
2015/09/15 08:32:57
I'd just like to resemble the buildbucket api, whe
|
| if options.clobber: |
| parameters['properties']['clobber'] = True |
| batch_req_body['builds'].append( |
| @@ -3073,6 +3083,11 @@ def CMDtry(parser, args): |
| help="Override which project to use. Projects are defined " |
| "server-side to define what default bot set to use") |
| group.add_option( |
| + "-p", "--property", dest="properties", action="append", default=[], |
| + help="Specify generic properties in the form -p key1=value1 -p " |
| + "key2=value2 etc (buildbucket only). The value will treated as" |
|
tandrii(chromium)
2015/09/14 14:52:22
nit: missing "be" : will BE treated
Michael Achenbach
2015/09/15 08:32:57
Done.
|
| + "json if decodable, or as string otherwise.") |
| + group.add_option( |
| "-n", "--name", help="Try job name; default to current branch name") |
| group.add_option( |
| "--use-rietveld", action="store_true", default=False, |
| @@ -3085,6 +3100,14 @@ def CMDtry(parser, args): |
| options, args = parser.parse_args(args) |
| auth_config = auth.extract_auth_config_from_options(options) |
| + if options.use_rietveld and options.properties: |
| + parser.error('Properties can only be specified with buildbucket') |
| + |
| + # Make sure that all properties are prop=value pairs. |
| + bad_params = [x for x in options.properties if '=' not in x] |
| + if bad_params: |
| + parser.error('Got properties with missing "=": %s' % bad_params) |
| + |
| if args: |
| parser.error('Unknown arguments: %s' % args) |