diff --git a/buildbot_gitea/reporter.py b/buildbot_gitea/reporter.py index effb23f..82f093c 100644 --- a/buildbot_gitea/reporter.py +++ b/buildbot_gitea/reporter.py @@ -24,7 +24,7 @@ import re class GiteaStatusPush(http.HttpStatusPushBase): name = "GiteaStatusPush" neededDetails = dict(wantProperties=True) - ssh_url_match = re.compile(r"(ssh://)?[\w+\-\_]+@[\w\.\-\_]+:?(\d*/)?(?P[\w_\-\.]+)/(?P[\w_\-\.]+)(\.git)?") + ssh_url_match = re.compile(r"(ssh://)?[\w+\-\_]+@[\w\.\-\_]+:?(\d*/)?(?P[\w_\-\.]+)/(?P[\w_\-\.]+)") @defer.inlineCallbacks def reconfigService(self, baseURL, token, @@ -117,10 +117,14 @@ class GiteaStatusPush(http.HttpStatusPushBase): if sha is None: # No special revision for this, so ignore it continue + + # Strip tailing .git to exclude it from re.match + ssh_url = re.sub('\.git$', '', sourcestamp['repository']) + if 'repository_name' in props: repository_name = props['repository_name'] else: - match = re.match(self.ssh_url_match, sourcestamp['repository']) + match = re.match(self.ssh_url_match, ssh_url) if match is not None: repository_name = match.group("repo_name") else: @@ -128,10 +132,11 @@ class GiteaStatusPush(http.HttpStatusPushBase): "Could not send status, " "build has no repository_name property for Gitea.") continue + if 'owner' in props: repository_owner = props['owner'] else: - match = re.match(self.ssh_url_match, sourcestamp['repository']) + match = re.match(self.ssh_url_match, ssh_url) if match is not None: repository_owner = match.group("owner") else: @@ -139,6 +144,7 @@ class GiteaStatusPush(http.HttpStatusPushBase): "Could not send status, " "build has no owner property for Gitea.") continue + try: target_url = build['url'] res = yield self.createStatus(