presubmit_support: Add flags for Gerrit project and target branch.
Will be used in a follow-up CL to initialize code-owners client.
Recipe-Nontrivial-Roll: build
Change-Id: Iefe9176320b4d1ae7715e88a8db132e815be76ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2717979
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index fdc884c..be35fc7 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -2958,13 +2958,16 @@
mock.patch('git_cl.Changelist.GetAuthor', return_value='author').start()
mock.patch('git_cl.Changelist.GetIssue', return_value=123456).start()
mock.patch('git_cl.Changelist.GetPatchset', return_value=7).start()
+ mock.patch(
+ 'git_cl.Changelist.GetRemoteBranch',
+ return_value=('origin', 'refs/remotes/origin/main')).start()
mock.patch('git_cl.PRESUBMIT_SUPPORT', 'PRESUBMIT_SUPPORT').start()
mock.patch('git_cl.Settings.GetRoot', return_value='root').start()
mock.patch('git_cl.time_time').start()
mock.patch('metrics.collector').start()
mock.patch('subprocess2.Popen').start()
- mock.patch('git_cl.Changelist.GetGerritProject',
- return_value='https://chromium-review.googlesource.com').start()
+ mock.patch(
+ 'git_cl.Changelist.GetGerritProject', return_value='project').start()
self.addCleanup(mock.patch.stopall)
self.temp_count = 0
@@ -2996,8 +2999,10 @@
'--root', 'root',
'--upstream', 'upstream',
'--verbose', '--verbose',
- '--author', 'author',
'--gerrit_url', 'https://chromium-review.googlesource.com',
+ '--gerrit_project', 'project',
+ '--gerrit_branch', 'refs/heads/main',
+ '--author', 'author',
'--issue', '123456',
'--patchset', '7',
'--commit',
@@ -3006,7 +3011,6 @@
'--all_files',
'--json_output', '/tmp/fake-temp2',
'--description_file', '/tmp/fake-temp1',
- '--gerrit_project', 'https://chromium-review.googlesource.com',
])
gclient_utils.FileWrite.assert_called_once_with(
'/tmp/fake-temp1', 'description')
@@ -3030,7 +3034,6 @@
git_cl.Changelist.GetAuthor.return_value = None
git_cl.Changelist.GetIssue.return_value = None
git_cl.Changelist.GetPatchset.return_value = None
- git_cl.Changelist.GetCodereviewServer.return_value = None
cl = git_cl.Changelist()
results = cl.RunHook(
@@ -3048,10 +3051,12 @@
'vpython', 'PRESUBMIT_SUPPORT',
'--root', 'root',
'--upstream', 'upstream',
+ '--gerrit_url', 'https://chromium-review.googlesource.com',
+ '--gerrit_project', 'project',
+ '--gerrit_branch', 'refs/heads/main',
'--upload',
'--json_output', '/tmp/fake-temp2',
'--description_file', '/tmp/fake-temp1',
- '--gerrit_project', 'https://chromium-review.googlesource.com',
])
gclient_utils.FileWrite.assert_called_once_with(
'/tmp/fake-temp1', 'description')
@@ -3075,7 +3080,6 @@
git_cl.Changelist.GetAuthor.return_value = None
git_cl.Changelist.GetIssue.return_value = None
git_cl.Changelist.GetPatchset.return_value = None
- git_cl.Changelist.GetCodereviewServer.return_value = None
cl = git_cl.Changelist()
results = cl.RunHook(
@@ -3095,10 +3099,12 @@
'vpython', 'PRESUBMIT_SUPPORT',
'--root', 'root',
'--upstream', 'upstream',
+ '--gerrit_url', 'https://chromium-review.googlesource.com',
+ '--gerrit_project', 'project',
+ '--gerrit_branch', 'refs/heads/main',
'--upload',
'--json_output', '/tmp/fake-temp2',
'--description_file', '/tmp/fake-temp1',
- '--gerrit_project', 'https://chromium-review.googlesource.com',
])
@mock.patch('sys.exit', side_effect=SystemExitMock)
@@ -3131,8 +3137,10 @@
'--root', 'root',
'--upstream', 'upstream',
'--verbose', '--verbose',
- '--author', 'author',
'--gerrit_url', 'https://chromium-review.googlesource.com',
+ '--gerrit_project', 'project',
+ '--gerrit_branch', 'refs/heads/main',
+ '--author', 'author',
'--issue', '123456',
'--patchset', '7',
'--post_upload',