changeset 8743:50906cedb924

hooks: clarify some comments
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 03 Nov 2020 12:52:03 +0100
parents 94a21c71df91
children 3f8cd215f5eb
files kallithea/config/middleware/simplegit.py kallithea/lib/hooks.py kallithea/lib/utils2.py kallithea/lib/vcs/ssh/base.py kallithea/lib/vcs/ssh/git.py
diffstat 5 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/config/middleware/simplegit.py	Tue Nov 03 12:45:29 2020 +0100
+++ b/kallithea/config/middleware/simplegit.py	Tue Nov 03 12:52:03 2020 +0100
@@ -89,7 +89,7 @@
                 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
 
--- a/kallithea/lib/hooks.py	Tue Nov 03 12:45:29 2020 +0100
+++ b/kallithea/lib/hooks.py	Tue Nov 03 12:52:03 2020 +0100
@@ -337,7 +337,7 @@
     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
--- a/kallithea/lib/utils2.py	Tue Nov 03 12:45:29 2020 +0100
+++ b/kallithea/lib/utils2.py	Tue Nov 03 12:52:03 2020 +0100
@@ -493,11 +493,11 @@
     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)
--- a/kallithea/lib/vcs/ssh/base.py	Tue Nov 03 12:45:29 2020 +0100
+++ b/kallithea/lib/vcs/ssh/base.py	Tue Nov 03 12:52:03 2020 +0100
@@ -89,12 +89,12 @@
         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()
 
--- a/kallithea/lib/vcs/ssh/git.py	Tue Nov 03 12:45:29 2020 +0100
+++ b/kallithea/lib/vcs/ssh/git.py	Tue Nov 03 12:52:03 2020 +0100
@@ -65,7 +65,7 @@
 
     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: