From a47f7a512b6612deb9b5d8326afdaebe676b4e83 Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Fri, 8 Jan 2021 15:49:39 -0600 Subject: [PATCH] Conform to code in GitLabStatusPush v2.9.4. I don't fully understand the impact of these API changes, but without them the status from buildbot upon a successful build was causing gitea to mark commits with a yellow circle instead of a green checkmark. Since GiteaStatusPush was based on GitLabStatusPush in the first place, I tried making it look more like its ancestor -- and now the commit status in gitea is working correctly. --- buildbot_gitea/reporter.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/buildbot_gitea/reporter.py b/buildbot_gitea/reporter.py index 5e32577..ae85d28 100644 --- a/buildbot_gitea/reporter.py +++ b/buildbot_gitea/reporter.py @@ -17,6 +17,7 @@ from buildbot.process.results import SUCCESS from buildbot.process.results import WARNINGS from buildbot.reporters import http from buildbot.util import httpclientservice +from buildbot.warnings import warn_deprecated import re @@ -27,16 +28,20 @@ class GiteaStatusPush(http.HttpStatusPushBase): def checkConfig(self, baseURL, token, startDescription=None, endDescription=None, context=None, verbose=False, wantProperties=True, **kwargs): - super().checkConfig(wantProperties=wantProperties, **kwargs) + super().checkConfig(wantProperties=wantProperties, + _has_old_arg_names={ + 'builders': False, + 'wantProperties': wantProperties is not True + }, **kwargs) @defer.inlineCallbacks def reconfigService(self, baseURL, token, startDescription=None, endDescription=None, - context=None, context_pr=None, verbose=False, + context=None, context_pr=None, verbose=False, wantProperties=True, warningAsSuccess=False, **kwargs): token = yield self.renderSecrets(token) - yield http.HttpStatusPushBase.reconfigService(self, **kwargs) + yield super().reconfigService(wantProperties=wantProperties, **kwargs) self.context = context or Interpolate('buildbot/%(prop:buildername)s') self.context_pr = context_pr or \ @@ -90,6 +95,21 @@ class GiteaStatusPush(http.HttpStatusPushBase): @defer.inlineCallbacks def send(self, build): + # the only case when this function is called is when the user derives this class, overrides + # send() and calls super().send(build) from there. + yield self._send_impl(build) + + @defer.inlineCallbacks + def sendMessage(self, reports): + build = reports[0]['builds'][0] + if self.send.__func__ is not GiteaStatusPush.send: + warn_deprecated('2.9.0', 'send() in reporters has been deprecated. Use sendMessage()') + yield self.send(build) + else: + yield self._send_impl(build) + + @defer.inlineCallbacks + def _send_impl(self, build): props = Properties.fromDict(build['properties']) props.master = self.master