Query Gerrit for destination branch in bot_update

This makes bot_update query Gerrit when syncing for Gerrit tryjobs.

The query will establish the actual destination branch of the CL,
which can be different from master (e.g. a feature branch).

Bot_update will ensure to use this destination branch for the repo
that corresponds to the CL's project. Both the main project or a
deps'ed project work.

Initially, this lives behind a flag that can be controlled in
downstream recipes. Eventually we'll set this to default after a
gradual roll-out.

Branches in branch-heads are not supported yet.

Bug: 740456
Change-Id: I4a0d50e2ca8fe90f8d29964a3ffab17291f7be60
Reviewed-on: https://chromium-review.googlesource.com/566824
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
This commit is contained in:
Michael Achenbach
2017-07-12 13:29:04 +02:00
committed by Commit Bot
parent bf1446791e
commit 7dadf05dad
31 changed files with 1050 additions and 133 deletions

View File

@@ -5,6 +5,27 @@
from recipe_engine import recipe_test_api
# Exemplary change. Note: This contains only a subset of the key/value pairs
# present in production to limit recipe simulation output.
EXAMPLE_CHANGE = {
'status': 'NEW',
'created': '2017-01-30 13:11:20.000000000',
'_number': '91827',
'change_id': 'Ideadbeef',
'project': 'chromium/src',
'has_review_started': False,
'branch': 'master',
'subject': 'Change title',
'revisions': {
'184ebe53805e102605d11f6b143486d15c23a09c': {
'_number': '1',
'commit': {
'message': 'Change commit message',
},
},
},
}
class GerritTestApi(recipe_test_api.RecipeTestApi):
def _make_gerrit_response_json(self, data):
@@ -23,29 +44,10 @@ class GerritTestApi(recipe_test_api.RecipeTestApi):
"revision": "67ebf73496383c6777035e374d2d664009e2aa5c"
})
def get_changes_response_data(self):
# Exemplary list of changes. Note: This contains only a subset of the
# key/value pairs present in production to limit recipe simulation output.
return self._make_gerrit_response_json([
{
'status': 'NEW',
'created': '2017-01-30 13:11:20.000000000',
'_number': '91827',
'change_id': 'Ideadbeef',
'project': 'chromium/src',
'has_review_started': False,
'branch': 'master',
'subject': 'Change title',
'revisions': {
'184ebe53805e102605d11f6b143486d15c23a09c': {
'_number': '1',
'commit': {
'message': 'Change commit message',
},
},
},
},
])
def get_one_change_response_data(self, **kwargs):
change = EXAMPLE_CHANGE.copy()
change.update(kwargs)
return self._make_gerrit_response_json([change])
def get_empty_changes_response_data(self):
return self._make_gerrit_response_json([])