# HG changeset patch # User Marcin Kuzminski # Date 1351345013 -7200 # Node ID 5085e51fba3abdf63badb779d07945e097db2fb1 # Parent 4abfb1afd9f5be8d3dd446deec5108fabd1f1ada Implemented #628: Pass server URL to rc-extensions hooks - updated rc-ext docs diff -r 4abfb1afd9f5 -r 5085e51fba3a rhodecode/config/rcextensions/__init__.py --- a/rhodecode/config/rcextensions/__init__.py Sat Oct 27 15:07:01 2012 +0200 +++ b/rhodecode/config/rcextensions/__init__.py Sat Oct 27 15:36:53 2012 +0200 @@ -75,18 +75,21 @@ # POST PUSH HOOK #============================================================================== -# this function will be executed after each push it's runned after the build-in -# hook that rhodecode uses for logging pushes +# this function will be executed after each push it's executed after the +# build-in hook that RhodeCode uses for logging pushes def _pushhook(*args, **kwargs): """ Post push hook kwargs available: + :param server_url: url of instance that triggered this hook + :param config: path to .ini config used + :param scm: type of VS 'git' or 'hg' :param username: name of user who pushed :param ip: ip of who pushed - :param action: pull + :param action: push :param repository: repository name - :param pushed_revs: generator of pushed revisions + :param pushed_revs: list of pushed revisions """ return 0 PUSH_HOOK = _pushhook @@ -96,15 +99,18 @@ # POST PULL HOOK #============================================================================== -# this function will be executed after each push it's runned after the build-in -# hook that rhodecode uses for logging pushes +# this function will be executed after each push it's executed after the +# build-in hook that RhodeCode uses for logging pulls def _pullhook(*args, **kwargs): """ Post pull hook kwargs available:: + :param server_url: url of instance that triggered this hook + :param config: path to .ini config used + :param scm: type of VS 'git' or 'hg' :param username: name of user who pulled - :param ip: ip of who pushed + :param ip: ip of who pulled :param action: pull :param repository: repository name """ diff -r 4abfb1afd9f5 -r 5085e51fba3a rhodecode/lib/middleware/simplegit.py --- a/rhodecode/lib/middleware/simplegit.py Sat Oct 27 15:07:01 2012 +0200 +++ b/rhodecode/lib/middleware/simplegit.py Sat Oct 27 15:36:53 2012 +0200 @@ -79,7 +79,7 @@ from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \ HTTPBadRequest, HTTPNotAcceptable -from rhodecode.lib.utils2 import safe_str, fix_PATH +from rhodecode.lib.utils2 import safe_str, fix_PATH, get_server_url from rhodecode.lib.base import BaseVCSController from rhodecode.lib.auth import get_container_username from rhodecode.lib.utils import is_valid_repo, make_ui @@ -189,6 +189,7 @@ # extras are injected into UI object and later available # in hooks executed by rhodecode from rhodecode import CONFIG + server_url = get_server_url(environ) extras = { 'ip': ipaddr, 'username': username, @@ -196,6 +197,7 @@ 'repository': repo_name, 'scm': 'git', 'config': CONFIG['__file__'], + 'server_url': server_url, 'make_lock': None, 'locked_by': [None, None] } diff -r 4abfb1afd9f5 -r 5085e51fba3a rhodecode/lib/middleware/simplehg.py --- a/rhodecode/lib/middleware/simplehg.py Sat Oct 27 15:07:01 2012 +0200 +++ b/rhodecode/lib/middleware/simplehg.py Sat Oct 27 15:36:53 2012 +0200 @@ -35,7 +35,7 @@ from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \ HTTPBadRequest, HTTPNotAcceptable -from rhodecode.lib.utils2 import safe_str, fix_PATH +from rhodecode.lib.utils2 import safe_str, fix_PATH, get_server_url from rhodecode.lib.base import BaseVCSController from rhodecode.lib.auth import get_container_username from rhodecode.lib.utils import make_ui, is_valid_repo, ui_sections @@ -152,6 +152,7 @@ # extras are injected into mercurial UI object and later available # in hg hooks executed by rhodecode from rhodecode import CONFIG + server_url = get_server_url(environ) extras = { 'ip': ipaddr, 'username': username, @@ -159,6 +160,7 @@ 'repository': repo_name, 'scm': 'hg', 'config': CONFIG['__file__'], + 'server_url': server_url, 'make_lock': None, 'locked_by': [None, None] } diff -r 4abfb1afd9f5 -r 5085e51fba3a rhodecode/lib/utils2.py --- a/rhodecode/lib/utils2.py Sat Oct 27 15:07:01 2012 +0200 +++ b/rhodecode/lib/utils2.py Sat Oct 27 15:36:53 2012 +0200 @@ -26,6 +26,8 @@ import re import time import datetime +import webob + from pylons.i18n.translation import _, ungettext from rhodecode.lib.vcs.utils.lazy import LazyProperty @@ -516,3 +518,8 @@ if url.password: url.password = 'XXXXX' return str(url) + + +def get_server_url(environ): + req = webob.Request(environ) + return req.host_url + req.script_name