Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check to make sure changes exist in BitBucket pushes #3480

Merged
merged 3 commits into from Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions readthedocs/core/views/hooks.py
Expand Up @@ -74,10 +74,10 @@ def build_branches(project, branch_list):
to_build - a list of branches that were built
not_building - a list of branches that we won't build
"""
to_build = set()
not_building = set()
for branch in branch_list:
versions = project.versions_from_branch_name(branch)
to_build = set()
not_building = set()
for version in versions:
log.info("(Branch Build) Processing %s:%s",
project.slug, version.slug)
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/restapi/views/integrations.py
Expand Up @@ -233,7 +233,8 @@ def handle_webhook(self):
try:
changes = self.request.data['push']['changes']
branches = [change['new']['name']
for change in changes]
for change in changes
if change.get('new')]
return self.get_response_push(self.project, branches)
except KeyError:
raise ParseError('Invalid request')
Expand Down
16 changes: 16 additions & 0 deletions readthedocs/rtd_tests/tests/test_api.py
Expand Up @@ -429,6 +429,22 @@ def test_bitbucket_webhook(self, trigger_build):
trigger_build.assert_has_calls(
[mock.call(force=True, version=mock.ANY, project=self.project)])

client.post(
'/api/v2/webhook/bitbucket/{0}/'.format(self.project.slug),
{
'push': {
'changes': [
{
'new': None,
},
],
},
},
format='json',
)
trigger_build.assert_not_called(
[mock.call(force=True, version=mock.ANY, project=self.project)])

def test_bitbucket_invalid_webhook(self, trigger_build):
"""Bitbucket webhook unhandled event."""
client = APIClient()
Expand Down