Indra Talip  committed c5b8924

refactoring for the forthcoming indexer tests to run without hitting a db.

attempting to run the an isolated test for testing the indexer fails as
it's expecting a database/caching layer to be active, not sure that this
necessary at least for testing so for the time-being it's disabled. might
need to re-enable getting the baseui from the db when the indexer is called
from the celery task.

  • Participants
  • Parent commits a0eabca

Comments (0)

Files changed (4)

File rhodecode/config/

     sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
-    repos_path = make_ui('db').configitems('paths')[0][1]
-    repo2db_mapper(ScmModel().repo_scan(repos_path),
+    baseui = make_ui('db')
+    repos_path = baseui.configitems('paths')[0][1]
+    repo2db_mapper(ScmModel().repo_scan(repos_path, baseui=baseui),
                    remove_obsolete=False, install_git_hook=False)
     config['base_path'] = repos_path

File rhodecode/controllers/admin/

 from rhodecode.lib.base import BaseController, render
 from rhodecode.lib.celerylib import tasks, run_task
 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
-    set_rhodecode_config, repo_name_slug
+    make_ui, set_rhodecode_config, repo_name_slug
 from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \
     RhodeCodeSetting, PullRequest, PullRequestReviewers
 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
         if setting_id == 'mapping':
             rm_obsolete = request.POST.get('destroy', False)
             log.debug('Rescanning directories with destroy=%s' % rm_obsolete)
-            initial = ScmModel().repo_scan()
+            initial = ScmModel().repo_scan(baseui=make_ui('db'))
             log.debug('invalidating all repositories')
             for repo_name in initial.keys():
                 invalidate_cache('get_repo_cached_%s' % repo_name)

File rhodecode/lib/indexers/

         if not repo_location:
             raise Exception('You have to provide repositories location')
-        self.repo_paths = ScmModel(sa).repo_scan(self.repo_location)
+        self.repo_paths = ScmModel(sa).repo_scan(self.repo_location, baseui=None)
         #filter repo list
         if repo_list:

File rhodecode/model/

 from rhodecode.lib import helpers as h
 from rhodecode.lib.utils2 import safe_str, safe_unicode
 from rhodecode.lib.auth import HasRepoPermissionAny, HasReposGroupPermissionAny
-from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, \
+from rhodecode.lib.utils import get_repos as get_filesystem_repos, \
     action_logger, EmptyChangeset, REMOVED_REPO_PAT
 from rhodecode.model import BaseModel
 from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \
         return q.ui_value
-    def repo_scan(self, repos_path=None):
+    def repo_scan(self, repos_path=None, baseui=None):
         Listing of repositories in given path. This path should not be a
         repository itself. Return a dictionary of repository objects
 'scanning for repositories in %s' % repos_path)
-        baseui = make_ui('db')
         repos = {}
         for name, path in get_filesystem_repos(repos_path, recursive=True):
             os.chmod(_hook_file, 0755)
-            log.debug('skipping writing hook file')
+            log.debug('skipping writing hook file')