##// END OF EJS Templates
Implemented #628: Pass server URL to rc-extensions hooks...
marcink -
r2969:5085e51f beta
parent child Browse files
Show More
@@ -75,18 +75,21 b' DELETE_REPO_HOOK = _dlhook'
75 # POST PUSH HOOK
75 # POST PUSH HOOK
76 #==============================================================================
76 #==============================================================================
77
77
78 # this function will be executed after each push it's runned after the build-in
78 # this function will be executed after each push it's executed after the
79 # hook that rhodecode uses for logging pushes
79 # build-in hook that RhodeCode uses for logging pushes
80 def _pushhook(*args, **kwargs):
80 def _pushhook(*args, **kwargs):
81 """
81 """
82 Post push hook
82 Post push hook
83 kwargs available:
83 kwargs available:
84
84
85 :param server_url: url of instance that triggered this hook
86 :param config: path to .ini config used
87 :param scm: type of VS 'git' or 'hg'
85 :param username: name of user who pushed
88 :param username: name of user who pushed
86 :param ip: ip of who pushed
89 :param ip: ip of who pushed
87 :param action: pull
90 :param action: push
88 :param repository: repository name
91 :param repository: repository name
89 :param pushed_revs: generator of pushed revisions
92 :param pushed_revs: list of pushed revisions
90 """
93 """
91 return 0
94 return 0
92 PUSH_HOOK = _pushhook
95 PUSH_HOOK = _pushhook
@@ -96,15 +99,18 b' PUSH_HOOK = _pushhook'
96 # POST PULL HOOK
99 # POST PULL HOOK
97 #==============================================================================
100 #==============================================================================
98
101
99 # this function will be executed after each push it's runned after the build-in
102 # this function will be executed after each push it's executed after the
100 # hook that rhodecode uses for logging pushes
103 # build-in hook that RhodeCode uses for logging pulls
101 def _pullhook(*args, **kwargs):
104 def _pullhook(*args, **kwargs):
102 """
105 """
103 Post pull hook
106 Post pull hook
104 kwargs available::
107 kwargs available::
105
108
109 :param server_url: url of instance that triggered this hook
110 :param config: path to .ini config used
111 :param scm: type of VS 'git' or 'hg'
106 :param username: name of user who pulled
112 :param username: name of user who pulled
107 :param ip: ip of who pushed
113 :param ip: ip of who pulled
108 :param action: pull
114 :param action: pull
109 :param repository: repository name
115 :param repository: repository name
110 """
116 """
@@ -79,7 +79,7 b' from paste.httpheaders import REMOTE_USE'
79 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
79 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
80 HTTPBadRequest, HTTPNotAcceptable
80 HTTPBadRequest, HTTPNotAcceptable
81
81
82 from rhodecode.lib.utils2 import safe_str, fix_PATH
82 from rhodecode.lib.utils2 import safe_str, fix_PATH, get_server_url
83 from rhodecode.lib.base import BaseVCSController
83 from rhodecode.lib.base import BaseVCSController
84 from rhodecode.lib.auth import get_container_username
84 from rhodecode.lib.auth import get_container_username
85 from rhodecode.lib.utils import is_valid_repo, make_ui
85 from rhodecode.lib.utils import is_valid_repo, make_ui
@@ -189,6 +189,7 b' class SimpleGit(BaseVCSController):'
189 # extras are injected into UI object and later available
189 # extras are injected into UI object and later available
190 # in hooks executed by rhodecode
190 # in hooks executed by rhodecode
191 from rhodecode import CONFIG
191 from rhodecode import CONFIG
192 server_url = get_server_url(environ)
192 extras = {
193 extras = {
193 'ip': ipaddr,
194 'ip': ipaddr,
194 'username': username,
195 'username': username,
@@ -196,6 +197,7 b' class SimpleGit(BaseVCSController):'
196 'repository': repo_name,
197 'repository': repo_name,
197 'scm': 'git',
198 'scm': 'git',
198 'config': CONFIG['__file__'],
199 'config': CONFIG['__file__'],
200 'server_url': server_url,
199 'make_lock': None,
201 'make_lock': None,
200 'locked_by': [None, None]
202 'locked_by': [None, None]
201 }
203 }
@@ -35,7 +35,7 b' from paste.httpheaders import REMOTE_USE'
35 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
35 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
36 HTTPBadRequest, HTTPNotAcceptable
36 HTTPBadRequest, HTTPNotAcceptable
37
37
38 from rhodecode.lib.utils2 import safe_str, fix_PATH
38 from rhodecode.lib.utils2 import safe_str, fix_PATH, get_server_url
39 from rhodecode.lib.base import BaseVCSController
39 from rhodecode.lib.base import BaseVCSController
40 from rhodecode.lib.auth import get_container_username
40 from rhodecode.lib.auth import get_container_username
41 from rhodecode.lib.utils import make_ui, is_valid_repo, ui_sections
41 from rhodecode.lib.utils import make_ui, is_valid_repo, ui_sections
@@ -152,6 +152,7 b' class SimpleHg(BaseVCSController):'
152 # extras are injected into mercurial UI object and later available
152 # extras are injected into mercurial UI object and later available
153 # in hg hooks executed by rhodecode
153 # in hg hooks executed by rhodecode
154 from rhodecode import CONFIG
154 from rhodecode import CONFIG
155 server_url = get_server_url(environ)
155 extras = {
156 extras = {
156 'ip': ipaddr,
157 'ip': ipaddr,
157 'username': username,
158 'username': username,
@@ -159,6 +160,7 b' class SimpleHg(BaseVCSController):'
159 'repository': repo_name,
160 'repository': repo_name,
160 'scm': 'hg',
161 'scm': 'hg',
161 'config': CONFIG['__file__'],
162 'config': CONFIG['__file__'],
163 'server_url': server_url,
162 'make_lock': None,
164 'make_lock': None,
163 'locked_by': [None, None]
165 'locked_by': [None, None]
164 }
166 }
@@ -26,6 +26,8 b''
26 import re
26 import re
27 import time
27 import time
28 import datetime
28 import datetime
29 import webob
30
29 from pylons.i18n.translation import _, ungettext
31 from pylons.i18n.translation import _, ungettext
30 from rhodecode.lib.vcs.utils.lazy import LazyProperty
32 from rhodecode.lib.vcs.utils.lazy import LazyProperty
31
33
@@ -516,3 +518,8 b' def obfuscate_url_pw(engine):'
516 if url.password:
518 if url.password:
517 url.password = 'XXXXX'
519 url.password = 'XXXXX'
518 return str(url)
520 return str(url)
521
522
523 def get_server_url(environ):
524 req = webob.Request(environ)
525 return req.host_url + req.script_name
General Comments 0
You need to be logged in to leave comments. Login now