# HG changeset patch # User RhodeCode Admin # Date 2024-01-29 11:15:15 # Node ID c32427b8c1cda958c358c4de868c19e9d2626ecc # Parent 6d0b768f71621164408067fd8d0d732d786e5d93 feat(upgrade): added feature to bulk upgrade hooks from 4.X -> 5.X fixes RCCE-34 diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -145,7 +145,7 @@ dev-srv: .PHONY: dev-srv-g ## run gunicorn multi process workers dev-srv-g: - gunicorn --paste .dev/dev.ini --bind=0.0.0.0:10020 --config=.dev/gunicorn_config.py --timeout=120 + gunicorn --paste .dev/dev.ini --bind=0.0.0.0:10020 --config=.dev/gunicorn_config.py --timeout=120 --reload # Default command on calling make diff --git a/rhodecode/api/views/server_api.py b/rhodecode/api/views/server_api.py --- a/rhodecode/api/views/server_api.py +++ b/rhodecode/api/views/server_api.py @@ -206,7 +206,7 @@ def rescan_repos(request, apiuser, remov try: rm_obsolete = Optional.extract(remove_obsolete) added, removed = repo2db_mapper(ScmModel().repo_scan(), - remove_obsolete=rm_obsolete) + remove_obsolete=rm_obsolete, force_hooks_rebuild=True) return {'added': added, 'removed': removed} except Exception: log.exception('Failed to run repo rescann') diff --git a/rhodecode/apps/admin/views/settings.py b/rhodecode/apps/admin/views/settings.py --- a/rhodecode/apps/admin/views/settings.py +++ b/rhodecode/apps/admin/views/settings.py @@ -217,7 +217,7 @@ class AdminSettingsView(BaseAppView): def settings_mapping(self): c = self.load_default_context() c.active = 'mapping' - + c.storage_path = VcsSettingsModel().get_repos_location() data = render('rhodecode:templates/admin/settings/settings.mako', self._get_template_context(c), self.request) html = formencode.htmlfill.render( @@ -245,7 +245,7 @@ class AdminSettingsView(BaseAppView): ScmModel().mark_for_invalidation(repo.repo_name, delete=True) filesystem_repos = ScmModel().repo_scan() - added, removed = repo2db_mapper(filesystem_repos, rm_obsolete) + added, removed = repo2db_mapper(filesystem_repos, rm_obsolete, force_hooks_rebuild=True) PermissionModel().trigger_permission_flush() def _repr(rm_repo): diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -508,7 +508,7 @@ def map_groups(path): return group -def repo2db_mapper(initial_repo_list, remove_obsolete=False): +def repo2db_mapper(initial_repo_list, remove_obsolete=False, force_hooks_rebuild=False): """ maps all repos given in initial_repo_list, non existing repositories are created, if remove_obsolete is True it also checks for db entries @@ -537,9 +537,10 @@ def repo2db_mapper(initial_repo_list, re group = map_groups(name) str_name = safe_str(name) db_repo = repo_model.get_by_repo_name(str_name) + # found repo that is on filesystem not in RhodeCode database if not db_repo: - log.info('repository %s not found, creating now', name) + log.info('repository `%s` not found in the database, creating now', name) added.append(name) desc = (repo.description if repo.description != 'unknown' @@ -570,7 +571,7 @@ def repo2db_mapper(initial_repo_list, re config = db_repo._config config.set('extensions', 'largefiles', '') repo = db_repo.scm_instance(config=config) - repo.install_hooks() + repo.install_hooks(force=force_hooks_rebuild) removed = [] if remove_obsolete: diff --git a/rhodecode/templates/admin/settings/settings_mapping.mako b/rhodecode/templates/admin/settings/settings_mapping.mako --- a/rhodecode/templates/admin/settings/settings_mapping.mako +++ b/rhodecode/templates/admin/settings/settings_mapping.mako @@ -5,6 +5,11 @@

${_('Import New Groups or Repositories')}

+ +

+ ${_('This function will scann all data under the current storage path location at')} ${c.storage_path} +

+
${h.checkbox('destroy',True)} diff --git a/rhodecode/tests/fixture_mods/fixture_utils.py b/rhodecode/tests/fixture_mods/fixture_utils.py --- a/rhodecode/tests/fixture_mods/fixture_utils.py +++ b/rhodecode/tests/fixture_mods/fixture_utils.py @@ -358,7 +358,7 @@ class TestRepoContainer(object): return Repository.get(self._repos[key]) def _create_repo(self, dump_name, backend_alias, config): - repo_name = '%s-%s' % (backend_alias, dump_name) + repo_name = f'{backend_alias}-{dump_name}' backend = get_backend(backend_alias) dump_extractor = self.dump_extractors[backend_alias] repo_path = dump_extractor(dump_name, repo_name) diff --git a/rhodecode/tests/lib/test_utils.py b/rhodecode/tests/lib/test_utils.py --- a/rhodecode/tests/lib/test_utils.py +++ b/rhodecode/tests/lib/test_utils.py @@ -231,8 +231,6 @@ def platform_encodes_filenames(): return path_with_latin1 != read_path - - def test_repo2db_mapper_groups(repo_groups): session = meta.Session() zombie_group, parent_group, child_group = repo_groups