Skip to content

Commit

Permalink
Merge jpihl/buildbot:fix-issue-2981 (PR #1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Oct 28, 2014
2 parents a090c23 + 97bfddc commit c52c2d5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
5 changes: 1 addition & 4 deletions master/buildbot/status/web/hooks/bitbucket.py
Expand Up @@ -38,10 +38,7 @@ def getChanges(request, options=None):
payload = json.loads(request.args['payload'][0])
repo_url = '%s%s' % (
payload['canon_url'], payload['repository']['absolute_url'])
project = (
request.args.get('project') if request.args.get('project') is not None
else ''
)
project = request.args.get('project', [''])[0]

changes = []
for commit in payload['commits']:
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/status/web/hooks/github.py
Expand Up @@ -37,8 +37,7 @@ def getChanges(request, options=None):
user = payload['repository']['owner']['name']
repo = payload['repository']['name']
repo_url = payload['repository']['url']
raw_project = request.args.get('project', None)
project = raw_project[0] if raw_project is not None else ''
project = request.args.get('project', [''])[0]
# This field is unused:
# private = payload['repository']['private']
changes = process_change(payload, user, repo, repo_url, project)
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/status/web/hooks/gitlab.py
Expand Up @@ -33,8 +33,7 @@ def getChanges(request, options=None):
user = payload['user_name']
repo = payload['repository']['name']
repo_url = payload['repository']['url']
raw_project = request.args.get('project', None)
project = raw_project[0] if raw_project is not None else ''
project = request.args.get('project', [''])[0]
codebase = request.args.get('codebase', None)
if codebase:
codebase = codebase[0]
Expand Down
17 changes: 17 additions & 0 deletions master/buildbot/test/unit/test_status_web_hooks_bitbucket.py
Expand Up @@ -250,3 +250,20 @@ def testWithNoJson(self):
request.setResponseCode.assert_called_with(
500, 'Error processing changes.')
self.assertEqual(len(self.flushLoggedErrors()), 1)

@inlineCallbacks
def testGitWithChangeAndProject(self):
change_dict = {
'payload': [gitJsonPayload],
'project': ['project-name']}

request = FakeRequest(change_dict)
request.uri = '/change_hook/bitbucket'
request.method = 'POST'

yield request.test_render(self.change_hook)

self.assertEqual(len(request.addedChanges), 1)
commit = request.addedChanges[0]

self.assertEqual(commit['project'], 'project-name')
3 changes: 3 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -155,6 +155,9 @@ Fixes
* Missing "name" and "email" properties received from Gerrit are now handled properly

* Fixed bug which made it impossible to specify the project when using the
BitBucket dialect.

Deprecations, Removals, and Non-Compatible Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit c52c2d5

Please sign in to comment.