Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
365793fe
Commit
365793fe
authored
Feb 13, 2013
by
Frederik Freso S. Olesen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Straight copy of hook_github() to hook_bitbucket().
parent
9de2d0a7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
weblate/trans/api.py
weblate/trans/api.py
+34
-0
weblate/urls.py
weblate/urls.py
+1
-0
No files found.
weblate/trans/api.py
View file @
365793fe
...
...
@@ -61,6 +61,40 @@ def update_project(request, project):
return
HttpResponse
(
'update triggered'
)
@
csrf_exempt
def
bitbucket_hook
(
request
):
'''
API to handle commit hooks from Bitbucket.
'''
if
not
appsettings
.
ENABLE_HOOKS
:
return
HttpResponseNotAllowed
([])
if
request
.
method
!=
'POST'
:
return
HttpResponseNotAllowed
([
'POST'
])
try
:
data
=
json
.
loads
(
request
.
POST
[
'payload'
])
except
(
ValueError
,
KeyError
):
return
HttpResponseBadRequest
(
'could not parse json!'
)
try
:
repo
=
'https://bitbucket.org/%s/%s.git'
%
(
data
[
'repository'
][
'owner'
][
'name'
],
data
[
'repository'
][
'name'
],
)
branch
=
data
[
'ref'
].
split
(
'/'
)[
-
1
]
except
KeyError
:
return
HttpResponseBadRequest
(
'could not parse json!'
)
logger
.
info
(
'received Bitbucket notification on repository %s, branch %s'
,
repo
,
branch
)
for
obj
in
SubProject
.
objects
.
filter
(
repo
=
repo
,
branch
=
branch
):
logger
.
info
(
'Bitbucket notification will update %s'
,
obj
)
thread
=
threading
.
Thread
(
target
=
obj
.
do_update
)
thread
.
start
()
return
HttpResponse
(
'update triggered'
)
@
csrf_exempt
def
github_hook
(
request
):
'''
...
...
weblate/urls.py
View file @
365793fe
...
...
@@ -183,6 +183,7 @@ urlpatterns = patterns('',
url
(
r'^hooks/update/(?P<project>[^/]*)/(?P<subproject>[^/]*)/$'
,
'weblate.trans.api.update_subproject'
),
url
(
r'^hooks/update/(?P<project>[^/]*)/$'
,
'weblate.trans.api.update_project'
),
url
(
r'^hooks/github/$'
,
'weblate.trans.api.github_hook'
),
url
(
r'^hooks/bitbucket/$'
,
'weblate.trans.api.bitbucket_hook'
),
url
(
r'^exports/stats/(?P<project>[^/]*)/(?P<subproject>[^/]*)/$'
,
'weblate.trans.api.export_stats'
,
name
=
'export-stats'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment