# HG changeset patch # User Mads Kiilerich # Date 1610324047 -3600 # Node ID 8c7bbe5bd03265b84c0754b292a0113815d02fb2 # Parent e40717c471a028cba5bf4a1a6d273fb4887f689e hooks: when overwriting non-Kallithea hooks, move the old hook to .bak Note: This will only happen when actually overwriting an unknown hook. Repeated hook installation will thus not clobber the existing .bak file until a non-Kallithea hook is found again. diff -r e40717c471a0 -r 8c7bbe5bd032 kallithea/model/scm.py --- a/kallithea/model/scm.py Sun Jan 10 01:28:48 2021 +0100 +++ b/kallithea/model/scm.py Mon Jan 11 01:14:07 2021 +0100 @@ -704,6 +704,10 @@ log.warning('skipping overwriting hook file %s', hook_file) else: log.debug('writing hook file %s', hook_file) + if other_hook: + backup_file = hook_file + '.bak' + log.warning('moving existing hook to %s', backup_file) + os.rename(hook_file, backup_file) try: fh, fn = tempfile.mkstemp(prefix=hook_file + '.tmp.') os.write(fh, tmpl.replace(b'_TMPL_', safe_bytes(kallithea.__version__))) diff -r e40717c471a0 -r 8c7bbe5bd032 kallithea/templates/admin/settings/settings_mapping.html --- a/kallithea/templates/admin/settings/settings_mapping.html Sun Jan 10 01:28:48 2021 +0100 +++ b/kallithea/templates/admin/settings/settings_mapping.html Mon Jan 11 01:14:07 2021 +0100 @@ -25,14 +25,14 @@ ${_('Install Git hooks')} - ${_("Verify if Kallithea's Git hooks are installed for each repository. Current hooks will be updated to the latest version.")} + ${_("Install Kallithea's internal hooks for all Git repositories where they are missing or can be upgraded. Existing hooks that don't seem to come from Kallithea will not be touched.")}
- ${_("If installing Git hooks, overwrite any existing hooks, even if they do not seem to come from Kallithea. WARNING: This operation will destroy any custom git hooks you may have deployed by hand!")} + ${_("Install Kallithea's internal hooks for all Git repositories. Existing hooks that don't seem to come from Kallithea will be disabled by renaming to .bak extension.")}