Index: git_cl.py |
diff --git a/git_cl.py b/git_cl.py |
index 3acfdbbdf5439b010bcfa42c242722820b24c036..a69efe672b14637f138bb66f51b473f059867b88 100755 |
--- a/git_cl.py |
+++ b/git_cl.py |
@@ -3456,6 +3456,7 @@ def CMDissue(parser, args): |
help='Lookup the branch(es) for the specified issues. If ' |
'no issues are specified, all branches with mapped ' |
'issues will be listed.') |
+ parser.add_option('--json', help='Path to JSON output file.') |
_add_codereview_select_options(parser) |
options, args = parser.parse_args(args) |
_process_codereview_select_options(parser, options) |
@@ -3471,11 +3472,16 @@ def CMDissue(parser, args): |
issue_branch_map.setdefault(cl.GetIssue(), []).append(branch) |
if not args: |
args = sorted(issue_branch_map.iterkeys()) |
+ result = {} |
for issue in args: |
if not issue: |
continue |
+ result[int(issue)] = issue_branch_map.get(int(issue)) |
print('Branch for issue number %s: %s' % ( |
issue, ', '.join(issue_branch_map.get(int(issue)) or ('None',)))) |
+ if options.json: |
+ with open(options.json, 'w') as f: |
tandrii(chromium)
2016/08/22 10:04:31
this should be a function for easy testing. Smth l
|
+ json.dump(result, f) |
else: |
cl = Changelist(codereview=options.forced_codereview) |
if len(args) > 0: |
@@ -3486,6 +3492,12 @@ def CMDissue(parser, args): |
'Maybe you want to run git cl status?') |
cl.SetIssue(issue) |
print('Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())) |
+ if options.json: |
+ with open(options.json, 'w') as f: |
+ json.dump({ |
+ 'issue': cl.GetIssue(), |
+ 'issue_url': cl.GetIssueURL(), |
+ }, f) |
return 0 |