diff --git a/rhodecode/config/environment.py b/rhodecode/config/environment.py --- a/rhodecode/config/environment.py +++ b/rhodecode/config/environment.py @@ -87,7 +87,8 @@ def load_environment(global_conf, app_co init_model(sa_engine_db1) repos_path = make_ui('db').configitems('paths')[0][1] - repo2db_mapper(ScmModel().repo_scan(repos_path)) + repo2db_mapper(ScmModel().repo_scan(repos_path), + remove_obsolete=True,) set_available_permissions(config) config['base_path'] = repos_path set_rhodecode_config(config) diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -451,13 +451,14 @@ def repo2db_mapper(initial_repo_list, re for name, repo in initial_repo_list.items(): group = map_groups(name) db_repo = rm.get_by_repo_name(name) + # found repo that is on filesystem not in RhodeCode database if not db_repo: log.info('repository %s not found creating now' % name) added.append(name) desc = (repo.description if repo.description != 'unknown' else '%s repository' % name) - rm.create_repo( + new_repo = rm.create_repo( repo_name=name, repo_type=repo.alias, description=desc, @@ -465,6 +466,10 @@ def repo2db_mapper(initial_repo_list, re owner=user, just_db=True ) + # we added that repo just now, and make sure it has githook + # installed + if new_repo.repo_type == 'git': + ScmModel().install_git_hook(new_repo.scm_instance) elif install_git_hook: if db_repo.repo_type == 'git': ScmModel().install_git_hook(db_repo.scm_instance)