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
d096ae50
Commit
d096ae50
authored
Mar 14, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced special hook for GitHub
parent
52cb1746
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
docs/admin.rst
docs/admin.rst
+9
-2
trans/api.py
trans/api.py
+32
-1
urls.py
urls.py
+1
-0
No files found.
docs/admin.rst
View file @
d096ae50
...
...
@@ -83,8 +83,15 @@ Interacting with others
-----------------------
You can trigger update of underlaying git repository for every subproject by
accessing URL :file:`/hooks/p/project/subproject/update/`. This can be used for
example as as Post-Receive URLs on Github.
accessing URL :file:`/hooks/p/project/subproject/update/`.
For GitHub, there is a special URL :file:`/hooks/github/`, which parses GitHub
notifications and updates related projects automatically.
.. note::
The GitHub notification relies on Git urls you use to be in form
git://github.com/owner/repo.git
.. _privileges:
...
...
trans/api.py
View file @
d096ae50
from
django.conf
import
settings
from
django.views.decorators.csrf
import
csrf_exempt
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
HttpResponseNotAllowed
,
HttpResponseNotFound
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
HttpResponseNotAllowed
,
HttpResponseNotFound
,
HttpResponseBadRequest
from
trans.models
import
Project
,
SubProject
,
Translation
,
Unit
,
Suggestion
,
Check
from
django.shortcuts
import
get_object_or_404
import
json
import
logging
logger
=
logging
.
getLogger
(
'weblate'
)
@
csrf_exempt
def
update_subproject
(
request
,
project
,
subproject
):
'''
...
...
@@ -15,3 +20,29 @@ def update_subproject(request, project, subproject):
obj
.
update_branch
()
obj
.
create_translations
()
return
HttpResponse
(
'updated'
)
@
csrf_exempt
def
github_hook
(
request
):
'''
API to handle commit hooks from Github.
'''
if
not
settings
.
ENABLE_HOOKS
:
return
HttpResponseNotAllowed
([])
if
request
.
method
!=
'POST'
:
return
HttpResponseNotAllowed
([
'POST'
])
try
:
data
=
json
.
loads
(
request
.
raw_post_data
)
except
ValueError
:
return
HttpResponseBadRequest
(
'could not parse json!'
)
repo
=
'git://github.com/%s/%s.git'
%
(
data
[
'repository'
][
'owner'
][
'name'
],
data
[
'repository'
][
'name'
],
)
logger
.
info
(
'received GitHub notification on repository %s'
,
repo
)
for
s
in
SubProject
.
objects
.
filter
(
repo
=
repo
):
logger
.
info
(
'GitHub notification will update %s'
,
s
)
s
.
update_branch
()
s
.
create_translations
()
return
HttpResponse
(
'updated'
)
urls.py
View file @
d096ae50
...
...
@@ -31,6 +31,7 @@ urlpatterns = patterns('',
url
(
r'^languages/(?P<lang>[^/]*)/$'
,
'trans.views.show_language'
),
url
(
r'^hooks/p/(?P<project>[^/]*)/(?P<subproject>[^/]*)/update/$'
,
'trans.api.update_subproject'
),
url
(
r'^hooks/github/$'
,
'trans.api.github_hook'
),
url
(
r'^js/get/(?P<checksum>[^/]*)/$'
,
'trans.views.get_string'
),
url
(
r'^js/ignore-check/(?P<check_id>[0-9]*)/$'
,
'trans.views.ignore_check'
),
...
...
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