# HG changeset patch # User domruf # Date 2016-04-29 16:53:49 # Node ID 5e501b6ee639c2cf25080ba8c3d53f4e4b6ad32e # Parent 85bb68f64597cadc7c0225b0a349cba978a36a76 hooks: if available, use sys.executable as executable for git hooks Windows doesn't necessarily have "python2" available in $PATH, but we still want to make sure we don't end up invoking a python3. Using the absolute path seems more safe. diff --git a/kallithea/config/post_receive_tmpl.py b/kallithea/config/post_receive_tmpl.py --- a/kallithea/config/post_receive_tmpl.py +++ b/kallithea/config/post_receive_tmpl.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2 import os import sys diff --git a/kallithea/config/pre_receive_tmpl.py b/kallithea/config/pre_receive_tmpl.py --- a/kallithea/config/pre_receive_tmpl.py +++ b/kallithea/config/pre_receive_tmpl.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2 import os import sys diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py --- a/kallithea/model/scm.py +++ b/kallithea/model/scm.py @@ -26,6 +26,7 @@ Original author and date, and relevant c """ import os +import sys import posixpath import re import time @@ -744,10 +745,12 @@ class ScmModel(BaseModel): if not os.path.isdir(loc): os.makedirs(loc) - tmpl_post = pkg_resources.resource_string( + tmpl_post = "#!/usr/bin/env %s\n" % sys.executable or 'python2' + tmpl_post += pkg_resources.resource_string( 'kallithea', jn('config', 'post_receive_tmpl.py') ) - tmpl_pre = pkg_resources.resource_string( + tmpl_pre = "#!/usr/bin/env %s\n" % sys.executable or 'python2' + tmpl_pre += pkg_resources.resource_string( 'kallithea', jn('config', 'pre_receive_tmpl.py') )