Skip to content

Commit 0859712

Browse files
committed
Allow tags from GitHub webhook
1 parent 69b69e0 commit 0859712

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

readthedocs/restapi/views/integrations.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import absolute_import
44
import json
55
import logging
6+
import re
67

78
from builtins import object
89
from rest_framework import permissions
@@ -159,11 +160,15 @@ def handle_webhook(self):
159160
# Handle push events and trigger builds
160161
if event == GITHUB_PUSH:
161162
try:
162-
branches = [self.data['ref'].replace('refs/heads/', '')]
163+
branches = [self._normalize_ref(self.data['ref'])]
163164
return self.get_response_push(self.project, branches)
164165
except KeyError:
165166
raise ParseError('Parameter "ref" is required')
166167

168+
def _normalize_ref(self, ref):
169+
pattern = re.compile(r'^refs/(heads|tags)/')
170+
return pattern.sub('', ref)
171+
167172

168173
class GitLabWebhookView(WebhookMixin, APIView):
169174

0 commit comments

Comments
 (0)