Commit 027d7020 authored by Quinten Yearsley's avatar Quinten Yearsley Committed by Commit Bot

[blinkpy] Tweak git cl issue

This would make it work correctly if anyone else runs
into the issue with some other message in the output
before the issue number, although this is still just
a hack.

Bug: 868469
Change-Id: Ib0a66a4374ae4db9807d11feb3d150d261ce0dd6
Reviewed-on: https://chromium-review.googlesource.com/1156994Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Quinten Yearsley <qyearsley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579560}
parent d3d59a97
......@@ -87,7 +87,15 @@ class GitCL(object):
return builders_by_bucket
def get_issue_number(self):
return self.run(['issue']).split()[2]
"""Returns the issue number as a string, or "None"."""
# Expected output of git cl issue looks like:
# "<Optional message> Issue number: 1234 (<url>)".
# Note: git cl gets the number from local git config, e.g.
# by running `git config branch.<branchname>.gerritissue`.
output = self.run(['issue']).split()
if 'number:' in output:
return output[output.index('number:') + 1]
return 'None'
def _get_cl_status(self):
return self.run(['status', '--field=status']).strip()
......
......@@ -121,7 +121,7 @@ class GitCLTest(unittest.TestCase):
def test_get_issue_number(self):
host = MockHost()
host.executive = MockExecutive(output='Issue number: 12345 (http://crrev.com/12345)')
host.executive = MockExecutive(output='Foo\nIssue number: 12345 (http://crrev.com/12345)')
git_cl = GitCL(host)
self.assertEqual(git_cl.get_issue_number(), '12345')
......@@ -131,6 +131,12 @@ class GitCLTest(unittest.TestCase):
git_cl = GitCL(host)
self.assertEqual(git_cl.get_issue_number(), 'None')
def test_get_issue_number_nothing_in_output(self):
host = MockHost()
host.executive = MockExecutive(output='Bogus output')
git_cl = GitCL(host)
self.assertEqual(git_cl.get_issue_number(), 'None')
def test_wait_for_try_jobs_timeout(self):
host = MockHost()
git_cl = GitCL(host)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment