Mercurial > kallithea
changeset 8839:25c51511c8eb
hooks: put repo_size and update hooks in kallithea namespace
Keep things separate.
Include missing migration steps for 642847355a10.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 11 Jan 2021 00:23:20 +0100 |
parents | 761efb9624fa |
children | 644b7a16d29c |
files | kallithea/alembic/versions/7ba0d2cad930_hooks_migrate_internal_hooks_to_.py kallithea/bin/vcs_hooks.py kallithea/controllers/admin/settings.py kallithea/model/db.py kallithea/model/forms.py kallithea/templates/admin/settings/settings_vcs.html kallithea/tests/functional/test_admin_settings.py |
diffstat | 7 files changed, 69 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kallithea/alembic/versions/7ba0d2cad930_hooks_migrate_internal_hooks_to_.py Mon Jan 11 00:23:20 2021 +0100 @@ -0,0 +1,57 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +"""hooks: migrate internal hooks to kallithea namespace + +Revision ID: 7ba0d2cad930 +Revises: f62826179f39 +Create Date: 2021-01-11 00:10:13.576586 + +""" + +# The following opaque hexadecimal identifiers ("revisions") are used +# by Alembic to track this migration script and its relations to others. +revision = '7ba0d2cad930' +down_revision = 'f62826179f39' +branch_labels = None +depends_on = None + +from alembic import op +from sqlalchemy import MetaData, Table + +from kallithea.model import db + + +meta = MetaData() + + +def upgrade(): + meta.bind = op.get_bind() + ui = Table(db.Ui.__tablename__, meta, autoload=True) + + ui.update(values={ + 'ui_key': 'changegroup.kallithea_update', + 'ui_value': 'python:', # value in db isn't used + }).where(ui.c.ui_key == 'changegroup.update').execute() + ui.update(values={ + 'ui_key': 'changegroup.kallithea_repo_size', + 'ui_value': 'python:', # value in db isn't used + }).where(ui.c.ui_key == 'changegroup.repo_size').execute() + + # 642847355a10 moved these hooks out of db - remove old entries + ui.delete().where(ui.c.ui_key == 'changegroup.push_logger').execute() + ui.delete().where(ui.c.ui_key == 'outgoing.pull_logger').execute() + + +def downgrade(): + pass
--- a/kallithea/bin/vcs_hooks.py Sun Jan 10 23:53:50 2021 +0100 +++ b/kallithea/bin/vcs_hooks.py Mon Jan 11 00:23:20 2021 +0100 @@ -48,7 +48,7 @@ def repo_size(ui, repo, hooktype=None, **kwargs): """Show size of Mercurial repository. - Called as Mercurial hook changegroup.repo_size after push. + Called as Mercurial hook changegroup.kallithea_repo_size after push. """ size_hg, size_root = get_scm_size('.hg', safe_str(repo.root)) @@ -69,7 +69,7 @@ """Update repo after push. The equivalent to 'hg update' but using the same Mercurial as everything else. - Called as Mercurial hook changegroup.update after push. + Called as Mercurial hook changegroup.kallithea_update after push. """ try: ui.pushbuffer(error=True, subproc=True)
--- a/kallithea/controllers/admin/settings.py Sun Jan 10 23:53:50 2021 +0100 +++ b/kallithea/controllers/admin/settings.py Mon Jan 11 00:23:20 2021 +0100 @@ -100,10 +100,10 @@ # HOOKS sett = db.Ui.get_by_key('hooks', db.Ui.HOOK_UPDATE) - sett.ui_active = form_result['hooks_changegroup_update'] + sett.ui_active = form_result['hooks_changegroup_kallithea_update'] sett = db.Ui.get_by_key('hooks', db.Ui.HOOK_REPO_SIZE) - sett.ui_active = form_result['hooks_changegroup_repo_size'] + sett.ui_active = form_result['hooks_changegroup_kallithea_repo_size'] ## EXTENSIONS sett = db.Ui.get_or_create('extensions', 'largefiles')
--- a/kallithea/model/db.py Sun Jan 10 23:53:50 2021 +0100 +++ b/kallithea/model/db.py Mon Jan 11 00:23:20 2021 +0100 @@ -330,8 +330,8 @@ _table_args_default_dict, ) - HOOK_UPDATE = 'changegroup.update' - HOOK_REPO_SIZE = 'changegroup.repo_size' + HOOK_UPDATE = 'changegroup.kallithea_update' + HOOK_REPO_SIZE = 'changegroup.kallithea_repo_size' ui_id = Column(Integer(), primary_key=True) ui_section = Column(String(255), nullable=False)
--- a/kallithea/model/forms.py Sun Jan 10 23:53:50 2021 +0100 +++ b/kallithea/model/forms.py Mon Jan 11 00:23:20 2021 +0100 @@ -384,8 +384,8 @@ v.ValidPath(), v.UnicodeString(strip=True, min=1, not_empty=True) ) - hooks_changegroup_update = v.StringBoolean(if_missing=False) - hooks_changegroup_repo_size = v.StringBoolean(if_missing=False) + hooks_changegroup_kallithea_update = v.StringBoolean(if_missing=False) + hooks_changegroup_kallithea_repo_size = v.StringBoolean(if_missing=False) extensions_largefiles = v.StringBoolean(if_missing=False) extensions_hggit = v.StringBoolean(if_missing=False)
--- a/kallithea/templates/admin/settings/settings_vcs.html Sun Jan 10 23:53:50 2021 +0100 +++ b/kallithea/templates/admin/settings/settings_vcs.html Mon Jan 11 00:23:20 2021 +0100 @@ -5,13 +5,13 @@ <div> <div class="checkbox"> <label> - ${h.checkbox('hooks_changegroup_repo_size','True')} + ${h.checkbox('hooks_changegroup_kallithea_repo_size','True')} ${_('Show repository size after push')} </label> </div> <div class="checkbox"> <label> - ${h.checkbox('hooks_changegroup_update','True')} + ${h.checkbox('hooks_changegroup_kallithea_update','True')} ${_('Update repository after push (hg update)')} </label> </div>
--- a/kallithea/tests/functional/test_admin_settings.py Sun Jan 10 23:53:50 2021 +0100 +++ b/kallithea/tests/functional/test_admin_settings.py Mon Jan 11 00:23:20 2021 +0100 @@ -91,13 +91,13 @@ def test_add_existing_builtin_hook(self): self.log_user() response = self.app.post(base.url('admin_settings_hooks'), - params=dict(new_hook_ui_key='changegroup.update', + params=dict(new_hook_ui_key='changegroup.kallithea_update', new_hook_ui_value='attempted_new_value', _session_csrf_secret_token=self.session_csrf_secret_token())) self.checkSessionFlash(response, 'Builtin hooks are read-only') response = response.follow() - response.mustcontain('changegroup.update') + response.mustcontain('changegroup.kallithea_update') def test_index_search(self): self.log_user()