# HG changeset patch # User Mads Kiilerich # Date 2019-12-27 01:58:57 # Node ID 45497a4524aab453092f983b8847e93ed0961adf # Parent 2b7aeb9d1546da7385c52c0c74cd05f54ed915b8 git: clean up safety check for overwriting hooks diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py --- a/kallithea/model/scm.py +++ b/kallithea/model/scm.py @@ -734,12 +734,11 @@ class ScmModel(object): log.debug('hook exists, checking if it is from kallithea') with open(_hook_file, 'rb') as f: data = f.read() - matches = re.compile(r'(?:%s)\s*=\s*(.*)' - % 'KALLITHEA_HOOK_VER').search(data) + matches = re.search(br'^KALLITHEA_HOOK_VER\s*=\s*(.*)$', data, flags=re.MULTILINE) if matches: try: ver = matches.groups()[0] - log.debug('got %s it is kallithea', ver) + log.debug('Found Kallithea hook - it has KALLITHEA_HOOK_VER %r', ver) has_hook = True except Exception: log.error(traceback.format_exc())