# HG changeset patch # User Mads Kiilerich # Date 2020-11-03 12:52:03 # Node ID 50906cedb924942dc15a56bf43577238919a37fc # Parent 94a21c71df91588b85d57d18abe31683675f53ac hooks: clarify some comments diff --git a/kallithea/config/middleware/simplegit.py b/kallithea/config/middleware/simplegit.py --- a/kallithea/config/middleware/simplegit.py +++ b/kallithea/config/middleware/simplegit.py @@ -89,7 +89,7 @@ class SimpleGit(BaseVCSController): baseui = make_ui() repo = db.Repository.get_by_repo_name(parsed_request.repo_name) scm_repo = repo.scm_instance - # Run hooks, like Mercurial outgoing.pull_logger does + # Run hooks like Mercurial outgoing.kallithea_log_pull_action does hooks.log_pull_action(ui=baseui, repo=scm_repo._repo) # Note: push hooks are handled by post-receive hook diff --git a/kallithea/lib/hooks.py b/kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py +++ b/kallithea/lib/hooks.py @@ -337,7 +337,7 @@ def handle_git_post_receive(repo_path, g try: baseui, repo = _hook_environment(repo_path) except HookEnvironmentError as e: - sys.stderr.write("Skipping Kallithea Git post-recieve hook %r.\nGit was apparently not invoked by Kallithea: %s\n" % (sys.argv[0], e)) + sys.stderr.write("Skipping Kallithea Git post-receive hook %r.\nGit was apparently not invoked by Kallithea: %s\n" % (sys.argv[0], e)) return 0 # the post push hook should never use the cached instance diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py +++ b/kallithea/lib/utils2.py @@ -493,11 +493,11 @@ def set_hook_environment(username, ip_ad Must always be called before anything with hooks are invoked. """ extras = { - 'ip': ip_addr, # used in log_push/pull_action action_logger + 'ip': ip_addr, # used in action_logger 'username': username, - 'action': action or 'push_local', # used in log_push_action_raw_ids action_logger + 'action': action or 'push_local', # used in process_pushed_raw_ids action_logger 'repository': repo_name, - 'scm': repo_alias, # used to pick hack in log_push_action_raw_ids + 'scm': repo_alias, 'config': kallithea.CONFIG['__file__'], # used by git hook to read config } os.environ['KALLITHEA_EXTRAS'] = json.dumps(extras) diff --git a/kallithea/lib/vcs/ssh/base.py b/kallithea/lib/vcs/ssh/base.py --- a/kallithea/lib/vcs/ssh/base.py +++ b/kallithea/lib/vcs/ssh/base.py @@ -89,12 +89,12 @@ class BaseSshHandler(object): assert self.db_repo.repo_name == self.repo_name # Set global hook environment up for 'push' actions. - # If pull actions should be served, the actual hook invocation will be - # hardcoded to 'pull' when log_pull_action is invoked (directly on Git, - # or through the Mercurial 'outgoing' hook). - # For push actions, the action in global hook environment is used (in - # handle_git_post_receive when it is called as Git post-receive hook, - # or in log_push_action through the Mercurial 'changegroup' hook). + # For push actions, the action in global hook environment is used in + # process_pushed_raw_ids (which it is called as Git post-receive hook, + # or Mercurial 'changegroup' hook). + # For pull actions, the actual hook in log_pull_action (called directly + # on Git, or through the 'outgoing' Mercurial hook) is hardcoded to + # ignore the environment action and always use 'pull'. set_hook_environment(self.authuser.username, client_ip, self.repo_name, self.vcs_type, 'push') return self._serve() diff --git a/kallithea/lib/vcs/ssh/git.py b/kallithea/lib/vcs/ssh/git.py --- a/kallithea/lib/vcs/ssh/git.py +++ b/kallithea/lib/vcs/ssh/git.py @@ -65,7 +65,7 @@ class GitSshHandler(base.BaseSshHandler) def _serve(self): if self.verb == 'git-upload-pack': # action 'pull' - # base class called set_hook_environment - action is hardcoded to '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) else: # probably verb 'git-receive-pack', action 'push' if not self.allow_push: