Chromium Code Reviews| Index: recipe_modules/git_cl/api.py |
| diff --git a/recipe_modules/git_cl/api.py b/recipe_modules/git_cl/api.py |
| index 8d2ad5c0d660600040b50f48ef25ca21420f4f0a..f9b1d0b89c1f48fe3d64b326f8253821b5e99408 100644 |
| --- a/recipe_modules/git_cl/api.py |
| +++ b/recipe_modules/git_cl/api.py |
| @@ -4,6 +4,19 @@ |
| from recipe_engine import recipe_api |
| +import string |
| + |
| +def clean_message(msg): |
| + """Cleans a commit message to be able to be printed on the command line.""" |
| + i = 0 |
| + for i in range(len(msg)): |
|
tandrii(chromium)
2016/06/22 14:41:15
1. Pythonic way:
for i, c in enumerate(msg):
martiniss
2016/06/22 22:47:33
Great, thanks.
|
| + if not msg[i] in string.printable: |
| + break |
| + if i < len(msg) - 1: |
| + msg = msg[:i] |
| + |
| + return msg |
| + |
| class GitClApi(recipe_api.RecipeApi): |
| def __call__(self, subcmd, args, name=None, **kwargs): |
| if not name: |
| @@ -39,3 +52,21 @@ class GitClApi(recipe_api.RecipeApi): |
| 'description', args, stdout=self.m.raw_io.output(), |
| stdin=self.m.raw_io.input(data=description), |
| name='git_cl set description', **kwargs) |
| + |
| + def upload(self, message, upload_args=None, **kwargs): |
| + upload_args = upload_args or [] |
| + # message can have unicode, which we can't pass on the command line, so |
|
tandrii(chromium)
2016/06/22 14:41:15
why not pass it in a temp file, or stdin? Patching
martiniss
2016/06/22 22:47:33
I do that below, in the call to set description.
tandrii(chromium)
2016/06/23 11:23:50
oh, well, then why do you even need to clean the m
martiniss
2016/06/23 18:35:41
It sends out an email immediately, which has the s
martiniss
2016/06/23 18:44:15
Look at https://codereview.chromium.org/2098603002
|
| + # upload it separately. Get a one line message for the subject for now. |
| + one_line_message = clean_message(message.split('\n')[0]) + "..." |
|
tandrii(chromium)
2016/06/22 14:41:15
message.splitlines()[0]
martiniss
2016/06/22 22:47:34
Done.
|
| + |
| + upload_args.extend(['-m', one_line_message]) |
|
tandrii(chromium)
2016/06/23 11:23:50
s/one_line_message/"whatever"
|
| + |
| + result = self('upload', upload_args, **kwargs) |
| + |
| + # Really set the description |
| + self.set_description(message) |
| + return result |
| + |
| + def issue(self, **kwargs): |
| + return self('issue', [], stdout=self.m.raw_io.output(), **kwargs) |
| + |