Example #1
0
    def _handle_push(self, repo, username, action, repo_name, revisions):
        """
        Triggers push action hooks

        :param repo: SCM repo
        :param username: username who pushes
        :param action: push/push_loca/push_remote
        :param repo_name: name of repo
        :param revisions: list of revisions that we pushed
        """
        self._handle_rc_scm_extras(username, repo_name, repo_alias=repo.alias)
        _scm_repo = repo._repo
        # trigger push hook
        if repo.alias == 'hg':
            log_push_action(_scm_repo.ui, _scm_repo, node=revisions[0])
        elif repo.alias == 'git':
            log_push_action(None, _scm_repo, _git_revs=revisions)
Example #2
0
    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)
        elif action == 'pull' and _hooks.get(pull_hook):
            log_pull_action(ui=baseui, repo=_repo._repo)
Example #3
0
    def _handle_push(self, repo, username, action, repo_name, revisions):
        """
        Triggers push action hooks

        :param repo: SCM repo
        :param username: username who pushes
        :param action: push/push_loca/push_remote
        :param repo_name: name of repo
        :param revisions: list of revisions that we pushed
        """
        from rhodecode import CONFIG
        from rhodecode.lib.base import _get_ip_addr
        try:
            from pylons import request
            environ = request.environ
        except TypeError:
            # we might use this outside of request context, let's fake the
            # environ data
            from webob import Request
            environ = Request.blank('').environ

        #trigger push hook
        extras = {
            'ip': _get_ip_addr(environ),
            'username': username,
            'action': 'push_local',
            'repository': repo_name,
            'scm': repo.alias,
            'config': CONFIG['__file__'],
            'server_url': get_server_url(environ),
            'make_lock': None,
            'locked_by': [None, None]
        }
        _scm_repo = repo._repo
        _set_extras(extras)
        if repo.alias == 'hg':
            log_push_action(_scm_repo.ui, _scm_repo, node=revisions[0])
        elif repo.alias == 'git':
            log_push_action(None, _scm_repo, _git_revs=revisions)