# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schamphele...@nokia.com>
# Date 1554753972 -7200
#      Mon Apr 08 22:06:12 2019 +0200
# Branch stable
# Node ID d02dee3a34716ea8930e366595e613572a3783e7
# Parent  cb33fa0fa1551384df6e2f4ab9ddd00d8567c69d
hooks: use /usr/bin/env only when needed

The use of /usr/bin/env is only needed for relative arguments (or to pass
variables in the environment, which we don't do). It is thus not needed in
case the Git hook interpreter is obtained via the ini file, or via
sys.executable (both of which are expected to be absolute paths).

diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py
--- a/kallithea/model/scm.py
+++ b/kallithea/model/scm.py
@@ -733,7 +733,9 @@ class ScmModel(object):
         FIXME This may not work on Windows and may need a shell wrapper script.
         To be revisited later...
         """
-        return kallithea.CONFIG.get('git_hook_interpreter') or sys.executable 
or 'python2'
+        return (kallithea.CONFIG.get('git_hook_interpreter')
+                or sys.executable
+                or '/usr/bin/env python2')
 
     def install_git_hooks(self, repo, force_create=False):
         """
@@ -749,11 +751,11 @@ class ScmModel(object):
         if not os.path.isdir(loc):
             os.makedirs(loc)
 
-        tmpl_post = "#!/usr/bin/env %s\n" % self._get_git_hook_interpreter()
+        tmpl_post = "#!%s\n" % self._get_git_hook_interpreter()
         tmpl_post += pkg_resources.resource_string(
             'kallithea', os.path.join('config', 'post_receive_tmpl.py')
         )
-        tmpl_pre = "#!/usr/bin/env %s\n" % self._get_git_hook_interpreter()
+        tmpl_pre = "#!%s\n" % self._get_git_hook_interpreter()
         tmpl_pre += pkg_resources.resource_string(
             'kallithea', os.path.join('config', 'pre_receive_tmpl.py')
         )
_______________________________________________
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general

Reply via email to