From 2737963b46b333e8db51f433b56af53fc17cfdc8 Mon Sep 17 00:00:00 2001 From: Nodir Turakulov Date: Wed, 17 Mar 2021 18:53:29 +0000 Subject: [PATCH] [git-cl] Expose Gerrit host and project Make git cl issue --json=- print Gerrit host and project as well. Change-Id: If53d681252eaa738f044a724ee45e70df4b1eef1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2766153 Commit-Queue: Nodir Turakulov Reviewed-by: Dean Berris Reviewed-by: Edward Lesmes --- git_cl.py | 4 +++- tests/git_cl_test.py | 22 ++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/git_cl.py b/git_cl.py index 3bf80cb19..4f248fcfa 100755 --- a/git_cl.py +++ b/git_cl.py @@ -3746,8 +3746,10 @@ def CMDissue(parser, args): print('Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())) if options.json: write_json(options.json, { - 'issue': cl.GetIssue(), + 'gerrit_host': cl.GetGerritHost(), + 'gerrit_project': cl.GetGerritProject(), 'issue_url': cl.GetIssueURL(), + 'issue': cl.GetIssue(), }) return 0 diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index a1515e8af..1a70abaee 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -2350,12 +2350,22 @@ class TestGitCl(unittest.TestCase): self.mockGit.config['branch.master.gerritissue'] = '123' self.mockGit.config['branch.master.gerritserver'] = ( 'https://chromium-review.googlesource.com') - self.calls = [ - (('write_json', 'output.json', - {'issue': 123, - 'issue_url': 'https://chromium-review.googlesource.com/123'}), - ''), - ] + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/chromium/src' + ) + self.calls = [( + ( + 'write_json', + 'output.json', + { + 'issue': 123, + 'issue_url': 'https://chromium-review.googlesource.com/123', + 'gerrit_host': 'chromium-review.googlesource.com', + 'gerrit_project': 'chromium/src', + }, + ), + '', + )] self.assertEqual(0, git_cl.main(['issue', '--json', 'output.json'])) def _common_GerritCommitMsgHookCheck(self):