Changeset - 5b3bbffea092
[Not reviewed]
Bradley M. Kuhn - 11 years ago 2014-07-03 01:05:36
bkuhn@sfconservancy.org
Cleanup of git hook installation
3 files changed with 9 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/config/post_receive_tmpl.py
Show inline comments
 
@@ -4,8 +4,8 @@ import sys
 

	
 
try:
 
    import kallithea
 
    RC_HOOK_VER = '_TMPL_'
 
    os.environ['RC_HOOK_VER'] = RC_HOOK_VER
 
    KALLITHEA_HOOK_VER = '_TMPL_'
 
    os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
 
    from kallithea.lib.hooks import handle_git_post_receive as _handler
 
except ImportError:
 
    if os.environ.get('RC_DEBUG_GIT_HOOK'):
kallithea/config/pre_receive_tmpl.py
Show inline comments
 
@@ -4,8 +4,8 @@ import sys
 

	
 
try:
 
    import kallithea
 
    RC_HOOK_VER = '_TMPL_'
 
    os.environ['RC_HOOK_VER'] = RC_HOOK_VER
 
    KALLITHEA_HOOK_VER = '_TMPL_'
 
    os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
 
    from kallithea.lib.hooks import handle_git_pre_receive as _handler
 
except ImportError:
 
    if os.environ.get('RC_DEBUG_GIT_HOOK'):
kallithea/model/scm.py
Show inline comments
 
@@ -853,7 +853,7 @@ class ScmModel(BaseModel):
 

	
 
        for h_type, tmpl in [('pre', tmpl_pre), ('post', tmpl_post)]:
 
            _hook_file = jn(loc, '%s-receive' % h_type)
 
            _rhodecode_hook = False
 
            has_hook = False
 
            log.debug('Installing git hook in repo %s' % repo)
 
            if os.path.exists(_hook_file):
 
                # let's take a look at this hook, maybe it's rhodecode ?
 
@@ -861,19 +861,19 @@ class ScmModel(BaseModel):
 
                with open(_hook_file, 'rb') as f:
 
                    data = f.read()
 
                    matches = re.compile(r'(?:%s)\s*=\s*(.*)'
 
                                         % 'RC_HOOK_VER').search(data)
 
                                         % 'KALLITHEA_HOOK_VER').search(data)
 
                    if matches:
 
                        try:
 
                            ver = matches.groups()[0]
 
                            log.debug('got %s it is rhodecode' % (ver))
 
                            _rhodecode_hook = True
 
                            has_hook = True
 
                        except Exception:
 
                            log.error(traceback.format_exc())
 
            else:
 
                # there is no hook in this dir, so we want to create one
 
                _rhodecode_hook = True
 
                has_hook = True
 

	
 
            if _rhodecode_hook or force_create:
 
            if has_hook or force_create:
 
                log.debug('writing %s hook file !' % (h_type,))
 
                try:
 
                    with open(_hook_file, 'wb') as f:
0 comments (0 inline, 0 general)