diff --git a/git_cl.py b/git_cl.py index 6e7e148d6..c02d23ef8 100755 --- a/git_cl.py +++ b/git_cl.py @@ -392,10 +392,12 @@ def _make_tryjob_schedule_requests(changelist, jobs, options, patchset): }) if options.ensure_value('revision', None): + remote, remote_branch = changelist.GetRemoteBranch() requests[-1]['scheduleBuild']['gitilesCommit'] = { 'host': gerrit_changes[0]['host'], 'project': gerrit_changes[0]['project'], - 'id': options.revision + 'id': options.revision, + 'ref': GetTargetRef(remote, remote_branch, None) } return requests diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 388bfa047..6100f6eee 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -86,6 +86,9 @@ class ChangelistMock(object): del patchset return self._gerrit_change + def GetRemoteBranch(self): + return ('origin', 'refs/remotes/origin/main') + class GitMocks(object): def __init__(self, config=None, branchref=None): @@ -3509,6 +3512,8 @@ class CMDTryTestCase(CMDTestCaseBase): @mock.patch('git_cl._call_buildbucket') def testScheduleOnBuildbucketWithRevision(self, mockCallBuildbucket): mockCallBuildbucket.return_value = {} + mock.patch('git_cl.Changelist.GetRemoteBranch', + return_value=('origin', 'refs/remotes/origin/main')).start() self.assertEqual(0, git_cl.main([ 'try', '-B', 'luci.chromium.try', '-b', 'win', '-b', 'linux', @@ -3548,6 +3553,7 @@ class CMDTryTestCase(CMDTestCaseBase): "host": "chromium-review.googlesource.com", "project": "depot_tools", "id": "beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeef", + "ref": "refs/heads/main", } }, }, @@ -3578,6 +3584,7 @@ class CMDTryTestCase(CMDTestCaseBase): "host": "chromium-review.googlesource.com", "project": "depot_tools", "id": "beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeef", + "ref": "refs/heads/main", } }, }], @@ -3801,7 +3808,8 @@ class MakeRequestsHelperTestCase(unittest.TestCase): requests[0]['scheduleBuild']['gitilesCommit'], { 'host': 'chromium-review.googlesource.com', 'id': 'ba5eba11', - 'project': 'depot_tools' + 'project': 'depot_tools', + 'ref': 'refs/heads/main', }) def testMakeRequestsHelperRetryFailedSet(self):