OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | 4 |
5 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
6 | 6 |
7 class GitClApi(recipe_api.RecipeApi): | 7 class GitClApi(recipe_api.RecipeApi): |
8 def __call__(self, subcmd, args, name=None, **kwargs): | 8 def __call__(self, subcmd, args, name=None, **kwargs): |
9 if not name: | 9 if not name: |
10 name = 'git_cl ' + subcmd | 10 name = 'git_cl ' + subcmd |
11 if 'cwd' not in kwargs: | 11 if 'cwd' not in kwargs: |
12 kwargs['cwd'] = (self.c and self.c.repo_location) or None | 12 kwargs['cwd'] = (self.c and self.c.repo_location) or None |
13 | 13 |
14 return self.m.step( | 14 return self.m.step( |
15 name, [self.package_repo_resource('git_cl.py')] + args, **kwargs) | 15 name, [self.package_repo_resource('git_cl.py')] + args, **kwargs) |
16 | 16 |
17 def get_description(self, **kwargs): | 17 def get_description(self, patch=None, codereview=None, **kwargs): |
18 return self('description', ['-d'], stdout=self.m.raw_io.output(), **kwargs) | 18 args = ['-d'] |
19 if patch or codereview: | |
20 assert patch and codereview, "Both patch and codereview must be provided" | |
iannucci
2016/05/12 00:25:52
why make them optional and defaulted to None then?
martiniss
2016/05/13 19:23:56
If one of them is provided, the other must be prov
iannucci
2016/05/23 19:52:33
Acknowledged.
| |
21 args.append(patch) | |
22 args.append('--%s' % codereview) | |
19 | 23 |
20 def set_description(self, description, **kwargs): | 24 return self('description', args, stdout=self.m.raw_io.output(), **kwargs) |
25 | |
26 def set_description(self, description, patch=None, codereview=None, **kwargs): | |
27 args = ['-n', '-'] | |
28 if patch or codereview: | |
29 assert patch and codereview, "Both patch and codereview must be provided" | |
30 args.append(patch) | |
31 args.append('--%s' % codereview) | |
32 | |
21 return self( | 33 return self( |
22 'description', ['-n', '-'], | 34 'description', args, stdout=self.m.raw_io.output(), |
23 stdout=self.m.raw_io.output(), | |
24 stdin=self.m.raw_io.input(data=description), | 35 stdin=self.m.raw_io.input(data=description), |
25 name='git_cl set description', **kwargs) | 36 name='git_cl set description', **kwargs) |
OLD | NEW |