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,
|
||||
|
@ -114,6 +117,10 @@ class GiteaStatusPush(http.HttpStatusPushBase):
|
|||
sha = sourcestamp['revision']
|
||||
if 'repository_name' in props:
|
||||
repository_name = props['repository_name']
|
||||
else:
|
||||
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, "
|
||||
|
@ -121,6 +128,10 @@ class GiteaStatusPush(http.HttpStatusPushBase):
|
|||
continue
|
||||
if 'owner' in props:
|
||||
repository_owner = props['owner']
|
||||
else:
|
||||
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, "
|
||||
|
|
|
@ -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