File tree 1 file changed +6
-1
lines changed
readthedocs/restapi/views
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 3
3
from __future__ import absolute_import
4
4
import json
5
5
import logging
6
+ import re
6
7
7
8
from builtins import object
8
9
from rest_framework import permissions
@@ -159,11 +160,15 @@ def handle_webhook(self):
159
160
# Handle push events and trigger builds
160
161
if event == GITHUB_PUSH :
161
162
try :
162
- branches = [self .data ['ref' ]. replace ( 'refs/heads/' , '' )]
163
+ branches = [self ._normalize_ref ( self . data ['ref' ])]
163
164
return self .get_response_push (self .project , branches )
164
165
except KeyError :
165
166
raise ParseError ('Parameter "ref" is required' )
166
167
168
+ def _normalize_ref (self , ref ):
169
+ pattern = re .compile (r'^refs/(heads|tags)/' )
170
+ return pattern .sub ('' , ref )
171
+
167
172
168
173
class GitLabWebhookView (WebhookMixin , APIView ):
169
174
You can’t perform that action at this time.
0 commit comments