Changeset - 8c7bbe5bd032
[Not reviewed]
default
0 2 0
Mads Kiilerich (mads) - 5 years ago 2021-01-11 01:14:07
mads@kiilerich.com
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.
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/model/scm.py
Show inline comments
 
@@ -704,6 +704,10 @@ class ScmModel(object):
 
                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__)))
kallithea/templates/admin/settings/settings_mapping.html
Show inline comments
 
@@ -25,14 +25,14 @@ ${h.form(url('admin_settings_mapping'), 
 
                            ${_('Install Git hooks')}
 
                        </label>
 
                    </div>
 
                    <span class="help-block">${_("Verify if Kallithea's Git hooks are installed for each repository. Current hooks will be updated to the latest version.")}</span>
 
                    <span class="help-block">${_("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.")}</span>
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('hooks_overwrite', True)}
 
                            ${_('Overwrite existing Git hooks')}
 
                            ${_('Install and overwrite Git hooks')}
 
                        </label>
 
                    </div>
 
                    <span class="help-block">${_("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!")}</span>
 
                    <span class="help-block">${_("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.")}</span>
 
                </div>
 
            </div>
 

	
0 comments (0 inline, 0 general)