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 |
| 12 if kwargs.get('suffix'): |
| 13 name = name + ' (%s)' % kwargs.pop('suffix') |
| 14 |
11 if 'cwd' not in kwargs: | 15 if 'cwd' not in kwargs: |
12 kwargs['cwd'] = (self.c and self.c.repo_location) or None | 16 kwargs['cwd'] = (self.c and self.c.repo_location) or None |
13 | 17 |
14 return self.m.step( | 18 return self.m.step( |
15 name, [self.package_repo_resource('git_cl.py')] + args, **kwargs) | 19 name, [self.package_repo_resource('git_cl.py'), subcmd] + args, |
| 20 **kwargs) |
16 | 21 |
17 def get_description(self, **kwargs): | 22 def get_description(self, patch=None, codereview=None, **kwargs): |
18 return self('description', ['-d'], stdout=self.m.raw_io.output(), **kwargs) | 23 args = ['-d'] |
| 24 if patch or codereview: |
| 25 assert patch and codereview, "Both patch and codereview must be provided" |
| 26 args.append('--%s' % codereview) |
| 27 args.append(patch) |
19 | 28 |
20 def set_description(self, description, **kwargs): | 29 return self('description', args, stdout=self.m.raw_io.output(), **kwargs) |
| 30 |
| 31 def set_description(self, description, patch=None, codereview=None, **kwargs): |
| 32 args = ['-n', '-'] |
| 33 if patch or codereview: |
| 34 assert patch and codereview, "Both patch and codereview must be provided" |
| 35 args.append(patch) |
| 36 args.append('--%s' % codereview) |
| 37 |
21 return self( | 38 return self( |
22 'description', ['-n', '-'], | 39 'description', args, stdout=self.m.raw_io.output(), |
23 stdout=self.m.raw_io.output(), | |
24 stdin=self.m.raw_io.input(data=description), | 40 stdin=self.m.raw_io.input(data=description), |
25 name='git_cl set description', **kwargs) | 41 name='git_cl set description', **kwargs) |
OLD | NEW |