Commits

Marcin Kuzminski committed 5085e51

Implemented #628: Pass server URL to rc-extensions hooks
- updated rc-ext docs

Comments (0)

Files changed (4)

rhodecode/config/rcextensions/__init__.py

 # 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
 # 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
     """

rhodecode/lib/middleware/simplegit.py

 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
         # 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,
             'repository': repo_name,
             'scm': 'git',
             'config': CONFIG['__file__'],
+            'server_url': server_url,
             'make_lock': None,
             'locked_by': [None, None]
         }

rhodecode/lib/middleware/simplehg.py

 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
         # 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,
             'repository': repo_name,
             'scm': 'hg',
             'config': CONFIG['__file__'],
+            'server_url': server_url,
             'make_lock': None,
             'locked_by': [None, None]
         }

rhodecode/lib/utils2.py

 import re
 import time
 import datetime
+import webob
+
 from pylons.i18n.translation import _, ungettext
 from rhodecode.lib.vcs.utils.lazy import LazyProperty
 
     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