diff --git a/git_cl.py b/git_cl.py index ad6fe01a2..4590e2108 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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) diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index e94e9129a..a9c1072dd 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -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 .""" + 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(