##// END OF EJS Templates
Cleanup of git hook installation
Bradley M. Kuhn -
r4205:5b3bbffe kallithea-2.2.5-r...
parent child Browse files
Show More
@@ -4,8 +4,8 b' import sys'
4
4
5 try:
5 try:
6 import kallithea
6 import kallithea
7 RC_HOOK_VER = '_TMPL_'
7 KALLITHEA_HOOK_VER = '_TMPL_'
8 os.environ['RC_HOOK_VER'] = RC_HOOK_VER
8 os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
9 from kallithea.lib.hooks import handle_git_post_receive as _handler
9 from kallithea.lib.hooks import handle_git_post_receive as _handler
10 except ImportError:
10 except ImportError:
11 if os.environ.get('RC_DEBUG_GIT_HOOK'):
11 if os.environ.get('RC_DEBUG_GIT_HOOK'):
@@ -4,8 +4,8 b' import sys'
4
4
5 try:
5 try:
6 import kallithea
6 import kallithea
7 RC_HOOK_VER = '_TMPL_'
7 KALLITHEA_HOOK_VER = '_TMPL_'
8 os.environ['RC_HOOK_VER'] = RC_HOOK_VER
8 os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
9 from kallithea.lib.hooks import handle_git_pre_receive as _handler
9 from kallithea.lib.hooks import handle_git_pre_receive as _handler
10 except ImportError:
10 except ImportError:
11 if os.environ.get('RC_DEBUG_GIT_HOOK'):
11 if os.environ.get('RC_DEBUG_GIT_HOOK'):
@@ -853,7 +853,7 b' class ScmModel(BaseModel):'
853
853
854 for h_type, tmpl in [('pre', tmpl_pre), ('post', tmpl_post)]:
854 for h_type, tmpl in [('pre', tmpl_pre), ('post', tmpl_post)]:
855 _hook_file = jn(loc, '%s-receive' % h_type)
855 _hook_file = jn(loc, '%s-receive' % h_type)
856 _rhodecode_hook = False
856 has_hook = False
857 log.debug('Installing git hook in repo %s' % repo)
857 log.debug('Installing git hook in repo %s' % repo)
858 if os.path.exists(_hook_file):
858 if os.path.exists(_hook_file):
859 # let's take a look at this hook, maybe it's rhodecode ?
859 # let's take a look at this hook, maybe it's rhodecode ?
@@ -861,19 +861,19 b' class ScmModel(BaseModel):'
861 with open(_hook_file, 'rb') as f:
861 with open(_hook_file, 'rb') as f:
862 data = f.read()
862 data = f.read()
863 matches = re.compile(r'(?:%s)\s*=\s*(.*)'
863 matches = re.compile(r'(?:%s)\s*=\s*(.*)'
864 % 'RC_HOOK_VER').search(data)
864 % 'KALLITHEA_HOOK_VER').search(data)
865 if matches:
865 if matches:
866 try:
866 try:
867 ver = matches.groups()[0]
867 ver = matches.groups()[0]
868 log.debug('got %s it is rhodecode' % (ver))
868 log.debug('got %s it is rhodecode' % (ver))
869 _rhodecode_hook = True
869 has_hook = True
870 except Exception:
870 except Exception:
871 log.error(traceback.format_exc())
871 log.error(traceback.format_exc())
872 else:
872 else:
873 # there is no hook in this dir, so we want to create one
873 # there is no hook in this dir, so we want to create one
874 _rhodecode_hook = True
874 has_hook = True
875
875
876 if _rhodecode_hook or force_create:
876 if has_hook or force_create:
877 log.debug('writing %s hook file !' % (h_type,))
877 log.debug('writing %s hook file !' % (h_type,))
878 try:
878 try:
879 with open(_hook_file, 'wb') as f:
879 with open(_hook_file, 'wb') as f:
General Comments 0
You need to be logged in to leave comments. Login now