Added owner and repo name detection in ssh url
This commit is contained in:
parent
4f66ddc5c3
commit
4661da0060
|
@ -19,10 +19,13 @@ from buildbot.reporters import http
|
|||
from buildbot.util import httpclientservice
|
||||
from buildbot.util import unicode2NativeString
|
||||
|
||||
import re
|
||||
|
||||
|
||||
class GiteaStatusPush(http.HttpStatusPushBase):
|
||||
name = "GiteaStatusPush"
|
||||
neededDetails = dict(wantProperties=True)
|
||||
ssh_url_match = re.compile(r"(ssh://)?[\w+\-\_]+@[\w+\.\-\_]:?\d*/(?P<owner>[\w_\-\.]+)/(?P<repo_name>[\w_\-\.]+)\.git")
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def reconfigService(self, baseURL, token,
|
||||
|
@ -115,17 +118,25 @@ class GiteaStatusPush(http.HttpStatusPushBase):
|
|||
if 'repository_name' in props:
|
||||
repository_name = props['repository_name']
|
||||
else:
|
||||
log.msg(
|
||||
"Could not send status, "
|
||||
"build has no repository_name property for Gitea.")
|
||||
continue
|
||||
match = re.match(self.ssh_url_match, sourcestamp['repository'])
|
||||
if match is not None:
|
||||
repository_name = match.group("repo_name")
|
||||
else:
|
||||
log.msg(
|
||||
"Could not send status, "
|
||||
"build has no repository_name property for Gitea.")
|
||||
continue
|
||||
if 'owner' in props:
|
||||
repository_owner = props['owner']
|
||||
else:
|
||||
log.msg(
|
||||
"Could not send status, "
|
||||
"build has no owner property for Gitea.")
|
||||
continue
|
||||
match = re.match(self.ssh_url_match, sourcestamp['repository'])
|
||||
if match is not None:
|
||||
repository_owner = match.group("owner")
|
||||
else:
|
||||
log.msg(
|
||||
"Could not send status, "
|
||||
"build has no owner property for Gitea.")
|
||||
continue
|
||||
try:
|
||||
sha = unicode2NativeString(sha)
|
||||
state = unicode2NativeString(state)
|
||||
|
|
|
@ -102,6 +102,20 @@ class TestGiteaStatusPush(
|
|||
build['complete'] = False
|
||||
self.sp.buildStarted(("build", 20, "started"), build)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_sshurl_noprops(self):
|
||||
self.TEST_REPO = u'git@gitea:buildbot/buildbot.git'
|
||||
build = yield self.setupBuildResults(SUCCESS)
|
||||
# we make sure proper calls to txrequests have been made
|
||||
self._http.expect(
|
||||
'post',
|
||||
'/api/v1/repos/buildbot/buildbot/statuses/d34db33fd43db33f',
|
||||
json={'state': 'pending',
|
||||
'target_url': 'http://localhost:8080/#builders/79/builds/0',
|
||||
'description': 'Build started.', 'name': 'buildbot/Builder0'})
|
||||
build['complete'] = False
|
||||
self.sp.buildStarted(("build", 20, "started"), build)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_noowner(self):
|
||||
self.setUpLogging()
|
||||
|
|
Loading…
Reference in New Issue
Block a user