Changeset - 3f8cd215f5eb
[Not reviewed]
default
0 3 0
Mads Kiilerich - 5 years ago 2020-11-02 15:40:18
mads@kiilerich.com
hooks: don't pass arguments to log_pull_action when calling from git - it uses set_hook_environment
3 files changed with 3 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/config/middleware/simplegit.py
Show inline comments
 
@@ -34,8 +34,6 @@ import re
 
from kallithea.config.middleware.pygrack import make_wsgi_app
 
from kallithea.lib import hooks
 
from kallithea.lib.base import BaseVCSController, get_path_info
 
from kallithea.lib.utils import make_ui
 
from kallithea.model import db
 

	
 

	
 
log = logging.getLogger(__name__)
 
@@ -86,11 +84,8 @@ class SimpleGit(BaseVCSController):
 
            if (parsed_request.cmd == 'info/refs' and
 
                parsed_request.service == 'git-upload-pack'
 
            ):
 
                baseui = make_ui()
 
                repo = db.Repository.get_by_repo_name(parsed_request.repo_name)
 
                scm_repo = repo.scm_instance
 
                # Run hooks like Mercurial outgoing.kallithea_log_pull_action does
 
                hooks.log_pull_action(ui=baseui, repo=scm_repo._repo)
 
                hooks.log_pull_action()
 
            # Note: push hooks are handled by post-receive hook
 

	
 
            return pygrack_app(environ, start_response)
kallithea/lib/hooks.py
Show inline comments
 
@@ -83,7 +83,7 @@ def repo_size(ui, repo, hooktype=None, *
 
    ui.status(safe_bytes(msg))
 

	
 

	
 
def log_pull_action(ui, repo, **kwargs):
 
def log_pull_action(*args, **kwargs):
 
    """Logs user last pull action
 

	
 
    Called as Mercurial hook outgoing.kallithea_log_pull_action or from Kallithea before invoking Git.
kallithea/lib/vcs/ssh/git.py
Show inline comments
 
@@ -16,7 +16,6 @@ import logging
 
import os
 

	
 
from kallithea.lib import hooks
 
from kallithea.lib.utils import make_ui
 
from kallithea.lib.vcs.ssh import base
 

	
 

	
 
@@ -66,7 +65,7 @@ class GitSshHandler(base.BaseSshHandler)
 
    def _serve(self):
 
        if self.verb == 'git-upload-pack': # action 'pull'
 
            # base class called set_hook_environment with 'push' action ... but log_pull_action ignores that and will 'pull'
 
            hooks.log_pull_action(ui=make_ui(), repo=self.db_repo.scm_instance._repo)
 
            hooks.log_pull_action()
 
        else: # probably verb 'git-receive-pack', action 'push'
 
            if not self.allow_push:
 
                self.exit('Push access to %r denied' % self.repo_name)
0 comments (0 inline, 0 general)