Changeset - 5e501b6ee639
[Not reviewed]
default
0 3 0
domruf - 10 years ago 2016-04-29 16:53:49
dominikruf@gmail.com
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.
3 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/config/post_receive_tmpl.py
Show inline comments
 
#!/usr/bin/env python2
 
import os
 
import sys
 

	
 
try:
 
    import kallithea
 
    KALLITHEA_HOOK_VER = '_TMPL_'
kallithea/config/pre_receive_tmpl.py
Show inline comments
 
#!/usr/bin/env python2
 
import os
 
import sys
 

	
 
try:
 
    import kallithea
 
    KALLITHEA_HOOK_VER = '_TMPL_'
kallithea/model/scm.py
Show inline comments
 
@@ -23,12 +23,13 @@ Original author and date, and relevant c
 
:author: marcink
 
:copyright: (c) 2013 RhodeCode GmbH, and others.
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
import os
 
import sys
 
import posixpath
 
import re
 
import time
 
import traceback
 
import logging
 
import cStringIO
 
@@ -741,16 +742,18 @@ class ScmModel(BaseModel):
 
        loc = jn(repo.path, 'hooks')
 
        if not repo.bare:
 
            loc = jn(repo.path, '.git', 'hooks')
 
        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')
 
        )
 

	
 
        for h_type, tmpl in [('pre', tmpl_pre), ('post', tmpl_post)]:
 
            _hook_file = jn(loc, '%s-receive' % h_type)
 
            has_hook = False
0 comments (0 inline, 0 general)