Commit 9011a5b7 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Add ref parameter when creating a try job

This fixes git cl try when revision is passed.

R=ehmaldonado@chromium.org

Bug: 1138785
Change-Id: Id5a067114426ed55409b1f200abf4d5a38fdbaa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2691312
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent 398091b1
......@@ -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
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment