Show More
@@ -427,7 +427,8 b' def map_groups(path):' | |||
|
427 | 427 | return group |
|
428 | 428 | |
|
429 | 429 | |
|
430 |
def repo2db_mapper(initial_repo_list, remove_obsolete=False |
|
|
430 | def repo2db_mapper(initial_repo_list, remove_obsolete=False, | |
|
431 | install_git_hook=False): | |
|
431 | 432 | """ |
|
432 | 433 | maps all repos given in initial_repo_list, non existing repositories |
|
433 | 434 | are created, if remove_obsolete is True it also check for db entries |
@@ -435,8 +436,11 b' def repo2db_mapper(initial_repo_list, re' | |||
|
435 | 436 | |
|
436 | 437 | :param initial_repo_list: list of repositories found by scanning methods |
|
437 | 438 | :param remove_obsolete: check for obsolete entries in database |
|
439 | :param install_git_hook: if this is True, also check and install githook | |
|
440 | for a repo if missing | |
|
438 | 441 | """ |
|
439 | 442 | from rhodecode.model.repo import RepoModel |
|
443 | from rhodecode.model.scm import ScmModel | |
|
440 | 444 | sa = meta.Session() |
|
441 | 445 | rm = RepoModel() |
|
442 | 446 | user = sa.query(User).filter(User.admin == True).first() |
@@ -446,7 +450,8 b' def repo2db_mapper(initial_repo_list, re' | |||
|
446 | 450 | |
|
447 | 451 | for name, repo in initial_repo_list.items(): |
|
448 | 452 | group = map_groups(name) |
|
449 |
|
|
|
453 | repo = rm.get_by_repo_name(name) | |
|
454 | if not repo: | |
|
450 | 455 | log.info('repository %s not found creating now' % name) |
|
451 | 456 | added.append(name) |
|
452 | 457 | desc = (repo.description |
@@ -460,6 +465,9 b' def repo2db_mapper(initial_repo_list, re' | |||
|
460 | 465 | owner=user, |
|
461 | 466 | just_db=True |
|
462 | 467 | ) |
|
468 | elif install_git_hook: | |
|
469 | if repo.repo_type == 'git': | |
|
470 | ScmModel().install_git_hook(repo.scm_instance) | |
|
463 | 471 | sa.commit() |
|
464 | 472 | removed = [] |
|
465 | 473 | if remove_obsolete: |
@@ -468,9 +476,13 b' def repo2db_mapper(initial_repo_list, re' | |||
|
468 | 476 | if repo.repo_name not in initial_repo_list.keys(): |
|
469 | 477 | log.debug("Removing non existing repository found in db %s" % |
|
470 | 478 | repo.repo_name) |
|
471 | removed.append(repo.repo_name) | |
|
472 | sa.delete(repo) | |
|
473 | sa.commit() | |
|
479 | try: | |
|
480 | sa.delete(repo) | |
|
481 | sa.commit() | |
|
482 | removed.append(repo.repo_name) | |
|
483 | except: | |
|
484 | #don't hold further removals on error | |
|
485 | log.error(traceback.format_exc()) | |
|
474 | 486 | |
|
475 | 487 | # clear cache keys |
|
476 | 488 | log.debug("Clearing cache keys now...") |
General Comments 0
You need to be logged in to leave comments.
Login now