Status reporter now sends status to head repository if the current build is from a pull request.
This commit is contained in:
parent
b1dc019e60
commit
b4d11a7058
|
@ -158,10 +158,15 @@ class GiteaStatusPush(http.ReporterBase):
|
|||
|
||||
for sourcestamp in sourcestamps:
|
||||
sha = sourcestamp['revision']
|
||||
repository_owner = None
|
||||
if sha is None:
|
||||
# No special revision for this, so ignore it
|
||||
continue
|
||||
if 'repository_name' in props:
|
||||
# If this is a pull request, send the status to the head repository
|
||||
if 'pr_id' in props:
|
||||
repository_name = props['head_reponame']
|
||||
repository_owner = props['head_owner']
|
||||
elif 'repository_name' in props:
|
||||
repository_name = props['repository_name']
|
||||
else:
|
||||
match = re.match(self.ssh_url_match, sourcestamp['repository'])
|
||||
|
@ -172,6 +177,7 @@ class GiteaStatusPush(http.ReporterBase):
|
|||
"Could not send status, "
|
||||
"build has no repository_name property for Gitea.")
|
||||
continue
|
||||
if repository_owner is None:
|
||||
if 'owner' in props:
|
||||
repository_owner = props['owner']
|
||||
else:
|
||||
|
|
|
@ -94,6 +94,24 @@ class TestGiteaStatusPush(
|
|||
build['results'] = FAILURE
|
||||
self.sp._got_event(('builds', 20, 'finished'), build)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_pullrequest(self):
|
||||
self.setupProps()
|
||||
self.reporter_test_props["pr_id"] = 42
|
||||
self.reporter_test_props["head_owner"] = 'foo'
|
||||
self.reporter_test_props["head_reponame"] = 'bar'
|
||||
build = yield self.setupBuildResults(SUCCESS)
|
||||
# we make sure proper calls to txrequests have been made
|
||||
self._http.expect(
|
||||
'post',
|
||||
'/api/v1/repos/foo/bar/statuses/d34db33fd43db33f',
|
||||
json={'state': 'success',
|
||||
'target_url': 'http://localhost:8080/#builders/79/builds/0',
|
||||
'description': 'Build done.', 'context': 'buildbot/pull_request/Builder0'})
|
||||
|
||||
build['complete'] = True
|
||||
self.sp._got_event(('builds', 20, 'finished'), build)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_sshurl(self):
|
||||
self.setupProps()
|
||||
|
|
|
@ -111,6 +111,8 @@ class GiteaHandler(BaseHookHandler):
|
|||
'head_repo_id': head['repo_id'],
|
||||
'head_repository': head['repo']['clone_url'],
|
||||
'head_git_ssh_url': head['repo']['ssh_url'],
|
||||
'head_owner': head['repo']['owner']['username'],
|
||||
'head_reponame': head['repo']['name'],
|
||||
'pr_id': pull_request['id'],
|
||||
'pr_number': pull_request['number'],
|
||||
'repository_name': repository['name'],
|
||||
|
|
Loading…
Reference in New Issue
Block a user