mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Add "git cl cherry-pick" for cherry picking a chain of CLs via Gerrit
Users who want to upload multiple cherry picks usually run "git cherry-pick" locally, multiple times. Gerrit does not recognize these changes as cherry picks and neither do other services that query cherry pick info from Gerrit, e.g. rubber stamper. For Gerrit to identify a change as a true cherry pick, you need to use their Cherry Pick Revision REST API endpoint. This new command uses it to create a chain of cherry pick CLs recognized by Gerrit. Bug: b/341792235 Change-Id: I4ba75da3901f6ea68c1debd65820e802da681798 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5756161 Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
@@ -1326,6 +1326,14 @@ def RestoreChange(host, change, msg=''):
|
||||
return ReadHttpJsonResponse(conn)
|
||||
|
||||
|
||||
def RebaseChange(host, change, base=None):
|
||||
"""Rebases a change."""
|
||||
path = f'changes/{change}/rebase'
|
||||
body = {'base': base} if base else {}
|
||||
conn = CreateHttpConn(host, path, reqtype='POST', body=body)
|
||||
return ReadHttpJsonResponse(conn)
|
||||
|
||||
|
||||
def SubmitChange(host, change):
|
||||
"""Submits a Gerrit change via Gerrit."""
|
||||
path = 'changes/%s/submit' % change
|
||||
@@ -1387,12 +1395,14 @@ def DeletePendingChangeEdit(host, change):
|
||||
ReadHttpResponse(conn, accept_statuses=[204, 404])
|
||||
|
||||
|
||||
def CherryPick(host, change, destination, revision='current'):
|
||||
def CherryPick(host, change, destination, revision='current', message=None):
|
||||
"""Create a cherry-pick commit from the given change, onto the given
|
||||
destination.
|
||||
"""
|
||||
path = 'changes/%s/revisions/%s/cherrypick' % (change, revision)
|
||||
body = {'destination': destination}
|
||||
if message:
|
||||
body['message'] = message
|
||||
conn = CreateHttpConn(host, path, reqtype='POST', body=body)
|
||||
return ReadHttpJsonResponse(conn)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user