Commit f20c5a4a authored by Nodir Turakulov's avatar Nodir Turakulov Committed by Commit Bot

[bot_update] Fix initialization from buildbucket

When checking if buildbucket.build_input.gitiles_commit exists, use
HasField protobuf method, as opposed to truth check. A protobuf message
field is always true.

Bug: 877161
Change-Id: Ie4a7e22b985776441a74283b09646e8837c326f1
Reviewed-on: https://chromium-review.googlesource.com/1196930
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
parent cc2bf0c0
......@@ -29,10 +29,12 @@ class BotUpdateApi(recipe_api.RecipeApi):
super(BotUpdateApi, self).__init__(*args, **kwargs)
def initialize(self):
gm = self.m.buildbucket.build_input.gitiles_commit
if self._revision is None and self._repository is None and gm:
build_input = self.m.buildbucket.build.input
if (self._revision is None and self._repository is None
and build_input.HasField('gitiles_commit')):
gm = build_input.gitiles_commit
self._revision = gm.id
self._repository = gm.host + '/' + gm.project
self._repository = 'https://%s/%s' % (gm.host, gm.project)
def __call__(self, name, cmd, **kwargs):
"""Wrapper for easy calling of bot_update."""
......
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