2018-09-27 16:32:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
from twisted.internet import defer
|
|
|
|
from twisted.python import log
|
|
|
|
|
|
|
|
from buildbot.steps.source.git import Git
|
|
|
|
|
|
|
|
|
|
|
|
class Gitea(Git):
|
|
|
|
"""
|
|
|
|
Source step that knows how to handle merge requests from
|
|
|
|
the Gitea webhook
|
|
|
|
"""
|
|
|
|
@defer.inlineCallbacks
|
2022-09-01 17:30:58 +02:00
|
|
|
def _fetch(self, *args, **kwargs):
|
|
|
|
res = yield super(Gitea, self)._fetch(*args, **kwargs)
|
2018-09-27 16:32:11 +02:00
|
|
|
if self.build.hasProperty("pr_id"):
|
|
|
|
remote = yield self._dovccmd(
|
2021-01-16 15:39:05 +01:00
|
|
|
['config', 'remote.pr_source.url'], collectStdout=True, abandonOnFailure=False)
|
2018-09-27 16:53:16 +02:00
|
|
|
if remote is None or remote.strip() is '':
|
2018-09-27 16:32:11 +02:00
|
|
|
yield self._dovccmd(
|
|
|
|
['remote', 'add', 'pr_source',
|
|
|
|
self.build.getProperty("head_git_ssh_url", None)])
|
|
|
|
else:
|
|
|
|
yield self._dovccmd(
|
|
|
|
['remote', 'set-url', 'pr_source',
|
|
|
|
self.build.getProperty("head_git_ssh_url", None)])
|
|
|
|
yield self._dovccmd(['fetch', 'pr_source'])
|
2018-09-27 16:53:16 +02:00
|
|
|
res = yield self._dovccmd(['merge', self.build.getProperty("head_sha", None)])
|
2022-09-01 17:30:58 +02:00
|
|
|
defer.returnValue(res)
|