Commit 26c8fd2b authored by tandrii@chromium.org's avatar tandrii@chromium.org

Fix git cl checkout when no branch has issues.

TBR=machenbach@chromium.org
BUG=579182

Review URL: https://codereview.chromium.org/1878613003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299843 0039d316-1c4b-4281-b951-d872f2087c98
parent 432fb944
......@@ -4550,10 +4550,10 @@ def CMDcheckout(parser, args):
target_issue = str(issue_arg.issue)
def find_issues(issueprefix):
key_and_issues = [x.split() for x in RunGit(
['config', '--local', '--get-regexp', r'branch\..*\.%s' % issueprefix])
.splitlines()]
for key, issue in key_and_issues:
output = RunGit(['config', '--local', '--get-regexp',
r'branch\..*\.%s' % issueprefix],
error_ok=True)
for key, issue in [x.split() for x in output.splitlines()]:
if issue == target_issue:
yield re.sub(r'branch\.(.*)\.%s' % issueprefix, r'\1', key)
......
......@@ -1180,6 +1180,19 @@ class TestGitCl(TestCase):
self.calls = self._checkout_calls()
self.assertEqual(1, git_cl.main(['checkout', '99999']))
def test_checkout_no_branch_issues(self):
"""Tests git cl checkout <issue>."""
self.calls = [
((['git', 'config', '--local', '--get-regexp',
'branch\\..*\\.rietveldissue'], ), '',
subprocess2.CalledProcessError(1, '', '', '', '')),
((['git', 'config', '--local', '--get-regexp',
'branch\\..*\\.gerritissue'], ), '',
subprocess2.CalledProcessError(1, '', '', '', '')),
]
self.assertEqual(1, git_cl.main(['checkout', '99999']))
if __name__ == '__main__':
git_cl.logging.basicConfig(
......
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