@@ -102,25 +102,25 @@ def log_pull_action(ui, repo, **kwargs):
if isfunction(callback):
kw = {}
kw.update(extras)
callback(**kw)
return 0
def log_push_action(ui, repo, **kwargs):
"""
Maps user last push action to new changeset id, from mercurial
:param ui:
:param repo:
:param repo: repo object containing the `ui` object
extras = dict(repo.ui.configitems('rhodecode_extras'))
username = extras['username']
repository = extras['repository']
action = extras['action'] + ':%s'
scm = extras['scm']
if scm == 'hg':
node = kwargs['node']
def get_revs(repo, rev_opt):
@@ -192,25 +192,25 @@ class SimpleGit(BaseVCSController):
#===================================================================
repo_path = os.path.join(safe_str(self.basepath), safe_str(repo_name))
log.debug('Repository path is %s' % repo_path)
baseui = make_ui('db')
self.__inject_extras(repo_path, baseui, extras)
try:
# invalidate cache on push
if action == 'push':
self._invalidate_cache(repo_name)
self._handle_githooks(action, baseui, environ)
self._handle_githooks(repo_name, action, baseui, environ)
log.info('%s action on GIT repo "%s"' % (action, repo_name))
app = self.__make_app(repo_name, repo_path)
return app(environ, start_response)
except Exception:
log.error(traceback.format_exc())
return HTTPInternalServerError()(environ, start_response)
def __make_app(self, repo_name, repo_path):
Make an wsgi application using dulserver
@@ -255,42 +255,42 @@ class SimpleGit(BaseVCSController):
'git-receive-pack': 'push',
'git-upload-pack': 'pull',
}
op = mapping[service_cmd]
self._git_stored_op = op
return op
else:
# try to fallback to stored variable as we don't know if the last
# operation is pull/push
op = getattr(self, '_git_stored_op', 'pull')
def _handle_githooks(self, action, baseui, environ):
def _handle_githooks(self, repo_name, action, baseui, environ):
from rhodecode.lib.hooks import log_pull_action, log_push_action
service = environ['QUERY_STRING'].split('=')
if len(service) < 2:
return
from rhodecode.model.db import Repository
_repo = Repository.get_by_repo_name(repo_name)
_repo = _repo.scm_instance
_repo._repo.ui = baseui
push_hook = 'pretxnchangegroup.push_logger'
pull_hook = 'preoutgoing.pull_logger'
_hooks = dict(baseui.configitems('hooks')) or {}
if action == 'push' and _hooks.get(push_hook):
log_push_action(ui=baseui, repo=repo._repo)
log_push_action(ui=baseui, repo=_repo._repo)
elif action == 'pull' and _hooks.get(pull_hook):
log_pull_action(ui=baseui, repo=repo._repo)
log_pull_action(ui=baseui, repo=_repo._repo)
def __inject_extras(self, repo_path, baseui, extras={}):
Injects some extra params into baseui instance
:param baseui: baseui instance
:param extras: dict with extra params to put into baseui
# make our hgweb quiet so it doesn't print output
baseui.setconfig('ui', 'quiet', 'true')
Status change: