-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Handle GitHub Push events with deleted: true
in the JSON
#6465
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,21 +359,23 @@ def get_digest(secret, msg): | |
def handle_webhook(self): | ||
# Get event and trigger other webhook events | ||
action = self.data.get('action', None) | ||
deleted = self.data.get('deleted', False) | ||
event = self.request.META.get(GITHUB_EVENT_HEADER, GITHUB_PUSH) | ||
webhook_github.send( | ||
Project, | ||
project=self.project, | ||
data=self.data, | ||
event=event, | ||
) | ||
# Handle push events and trigger builds | ||
if event == GITHUB_PUSH: | ||
# Don't build a branch if it's a push that was actually a delete | ||
# https://developer.github.com/v3/activity/events/types/#pushevent | ||
if event == GITHUB_PUSH and not deleted: | ||
try: | ||
branches = [self._normalize_ref(self.data['ref'])] | ||
return self.get_response_push(self.project, branches) | ||
except KeyError: | ||
raise ParseError('Parameter "ref" is required') | ||
if event in (GITHUB_CREATE, GITHUB_DELETE): | ||
if event in (GITHUB_CREATE, GITHUB_DELETE) or (event == GITHUB_PUSH and deleted): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already subscribe to create and delete events that does the same. But I think this is still useful for users with old webhooks that only have the push event. We should also build when there is a push event with |
||
return self.sync_versions(self.project) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably not the most efficient thing we could be doing. We could grab the branch name from the Push and delete it explicitly, but this seemed like the easiest implementation. |
||
|
||
if ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
created=True
this wouldn't trigger a new build, because the version doesn't exist yet in read the docs.readthedocs.org/readthedocs/core/views/hooks.py
Lines 50 to 52 in 2e67b7d
We should check that created is
False
here too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an existing bug though, right? I don't know when we want to trigger a build when a user creates a new branch on a push?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, a push event + deleted or push event + created should trigger a version sync, not a build (because it will fail when deteled=True and it wouldn't to anything if created=True)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I understand, so we need to check for
created
on the push as well 👍