##// END OF EJS Templates
Backported fixe for #834 hooks error on remote pulling
marcink -
r3879:51596d9e default
parent child Browse files
Show More
@@ -405,6 +405,31 class ScmModel(BaseModel):
405 self.sa.add(repo)
405 self.sa.add(repo)
406 return repo
406 return repo
407
407
408 def _handle_rc_scm_extras(self, username, repo_name, repo_alias,
409 action=None):
410 from rhodecode import CONFIG
411 from rhodecode.lib.base import _get_ip_addr
412 try:
413 from pylons import request
414 environ = request.environ
415 except TypeError:
416 # we might use this outside of request context, let's fake the
417 # environ data
418 from webob import Request
419 environ = Request.blank('').environ
420 extras = {
421 'ip': _get_ip_addr(environ),
422 'username': username,
423 'action': action or 'push_local',
424 'repository': repo_name,
425 'scm': repo_alias,
426 'config': CONFIG['__file__'],
427 'server_url': get_server_url(environ),
428 'make_lock': None,
429 'locked_by': [None, None]
430 }
431 _set_extras(extras)
432
408 def _handle_push(self, repo, username, action, repo_name, revisions):
433 def _handle_push(self, repo, username, action, repo_name, revisions):
409 """
434 """
410 Triggers push action hooks
435 Triggers push action hooks
@@ -415,31 +440,9 class ScmModel(BaseModel):
415 :param repo_name: name of repo
440 :param repo_name: name of repo
416 :param revisions: list of revisions that we pushed
441 :param revisions: list of revisions that we pushed
417 """
442 """
418 from rhodecode import CONFIG
443 self._handle_rc_scm_extras(username, repo_name, repo_alias=repo.alias)
419 from rhodecode.lib.base import _get_ip_addr
420 try:
421 from pylons import request
422 environ = request.environ
423 except TypeError:
424 # we might use this outside of request context, let's fake the
425 # environ data
426 from webob import Request
427 environ = Request.blank('').environ
428
429 #trigger push hook
430 extras = {
431 'ip': _get_ip_addr(environ),
432 'username': username,
433 'action': 'push_local',
434 'repository': repo_name,
435 'scm': repo.alias,
436 'config': CONFIG['__file__'],
437 'server_url': get_server_url(environ),
438 'make_lock': None,
439 'locked_by': [None, None]
440 }
441 _scm_repo = repo._repo
444 _scm_repo = repo._repo
442 _set_extras(extras)
445 # trigger push hook
443 if repo.alias == 'hg':
446 if repo.alias == 'hg':
444 log_push_action(_scm_repo.ui, _scm_repo, node=revisions[0])
447 log_push_action(_scm_repo.ui, _scm_repo, node=revisions[0])
445 elif repo.alias == 'git':
448 elif repo.alias == 'git':
@@ -471,7 +474,10 class ScmModel(BaseModel):
471 if repo.alias == 'git':
474 if repo.alias == 'git':
472 repo.fetch(clone_uri)
475 repo.fetch(clone_uri)
473 else:
476 else:
477 self._handle_rc_scm_extras(username, dbrepo.repo_name,
478 repo.alias, action='push_remote')
474 repo.pull(clone_uri)
479 repo.pull(clone_uri)
480
475 self.mark_for_invalidation(repo_name)
481 self.mark_for_invalidation(repo_name)
476 except Exception:
482 except Exception:
477 log.error(traceback.format_exc())
483 log.error(traceback.format_exc())
General Comments 0
You need to be logged in to leave comments. Login now