# HG changeset patch # User Mads Kiilerich # Date 1533687791 -7200 # Node ID efe7ed15e12c4d6dd250881e6b9585e14fdbeb6b # Parent 51ef4b681634a051345d441d2cd9b2cbfa90a9ca hooks: cleanup and documentation of the installed Git hooks diff -r 51ef4b681634 -r efe7ed15e12c kallithea/config/post_receive_tmpl.py --- a/kallithea/config/post_receive_tmpl.py Wed Aug 08 02:23:11 2018 +0200 +++ b/kallithea/config/post_receive_tmpl.py Wed Aug 08 02:23:11 2018 +0200 @@ -1,28 +1,34 @@ +"""Kallithea Git hook + +This hook is installed and maintained by Kallithea. It will be overwritten +by Kallithea - don't customize it manually! + +When Kallithea invokes Git, the KALLITHEA_EXTRAS environment variable will +contain additional info like the Kallithea instance and user info that this +hook will use. +""" + import os import sys -# set output mode on windows to binary for stderr -# this prevents python (or the windows console) from replacing \n with \r\n -# git doesn't display remote output lines that contain \r -# and therefore without this modification git would displayes empty lines -# instead of the exception output +# Set output mode on windows to binary for stderr. +# This prevents python (or the windows console) from replacing \n with \r\n. +# Git doesn't display remote output lines that contain \r, +# and therefore without this modification git would display empty lines +# instead of the exception output. if sys.platform == "win32": import msvcrt msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) KALLITHEA_HOOK_VER = '_TMPL_' os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER -from kallithea.lib.hooks import handle_git_post_receive as _handler +import kallithea.lib.hooks def main(): repo_path = os.path.abspath('.') git_stdin_lines = sys.stdin.readlines() - # os.environ is modified here by a subprocess call that - # runs git and later git executes this hook. - # Environ gets some additional info from kallithea system - # like IP or username from basic-auth - sys.exit(_handler(repo_path, git_stdin_lines, os.environ)) + sys.exit(kallithea.lib.hooks.handle_git_post_receive(repo_path, git_stdin_lines, os.environ)) if __name__ == '__main__': diff -r 51ef4b681634 -r efe7ed15e12c kallithea/config/pre_receive_tmpl.py --- a/kallithea/config/pre_receive_tmpl.py Wed Aug 08 02:23:11 2018 +0200 +++ b/kallithea/config/pre_receive_tmpl.py Wed Aug 08 02:23:11 2018 +0200 @@ -1,28 +1,34 @@ +"""Kallithea Git hook + +This hook is installed and maintained by Kallithea. It will be overwritten +by Kallithea - don't customize it manually! + +When Kallithea invokes Git, the KALLITHEA_EXTRAS environment variable will +contain additional info like the Kallithea instance and user info that this +hook will use. +""" + import os import sys -# set output mode on windows to binary for stderr -# this prevents python (or the windows console) from replacing \n with \r\n -# git doesn't display remote output lines that contain \r -# and therefore without this modification git would displayes empty lines -# instead of the exception output +# Set output mode on windows to binary for stderr. +# This prevents python (or the windows console) from replacing \n with \r\n. +# Git doesn't display remote output lines that contain \r, +# and therefore without this modification git would display empty lines +# instead of the exception output. if sys.platform == "win32": import msvcrt msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) KALLITHEA_HOOK_VER = '_TMPL_' os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER -from kallithea.lib.hooks import handle_git_pre_receive as _handler +import kallithea.lib.hooks def main(): repo_path = os.path.abspath('.') git_stdin_lines = sys.stdin.readlines() - # os.environ is modified here by a subprocess call that - # runs git and later git executes this hook. - # Environ gets some additional info from kallithea system - # like IP or username from basic-auth - sys.exit(_handler(repo_path, git_stdin_lines, os.environ)) + sys.exit(kallithea.lib.hooks.handle_git_pre_receive(repo_path, git_stdin_lines, os.environ)) if __name__ == '__main__':