Changeset - 5eb6805c2a4f
[Not reviewed]
default
1 2 0
Thomas De Schampheleire - 7 years ago 2018-11-18 20:02:17
thomas.de_schampheleire@nokia.com
cli: convert 'gearbox update-repoinfo' into 'kallithea-cli repo-update-metadata'

The --update-only option is replaced by listing repository names as separate command line arguments.

The --invalidate-cache option is dropped and we just always invalidate all caches.
3 files changed with 37 insertions and 73 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_repo.py
Show inline comments
 
@@ -23,6 +23,9 @@ import click
 
import kallithea.bin.kallithea_cli_base as cli_base
 

	
 
from kallithea.lib.utils import repo2db_mapper
 
from kallithea.lib.utils2 import safe_unicode
 
from kallithea.model.db import Repository
 
from kallithea.model.meta import Session
 
from kallithea.model.scm import ScmModel
 

	
 
@cli_base.register_command(config_file_initialize_app=True)
 
@@ -46,3 +49,37 @@ def repo_scan(remove_missing):
 
    if removed:
 
        click.echo('%s: %s' % ('Removed' if remove_missing else 'Missing',
 
                          ', '.join(removed)))
 

	
 
@cli_base.register_command(config_file_initialize_app=True)
 
@click.argument('repositories', nargs=-1)
 
def repo_update_metadata(repositories):
 
    """
 
    Update repository metadata in database from repository content.
 

	
 
    In normal operation, Kallithea will keep caches up-to-date
 
    automatically. However, if repositories are externally modified, e.g. by
 
    a direct push via the filesystem rather than via a Kallithea URL,
 
    Kallithea is not aware of it. In this case, you should manually run this
 
    command to update the repository cache.
 

	
 
    If no repositories are specified, the caches of all repositories are
 
    updated.
 
    """
 
    if not repositories:
 
        repo_list = Repository.query().all()
 
    else:
 
        repo_names = [safe_unicode(n.strip()) for n in repositories]
 
        repo_list = list(Repository.query()
 
                        .filter(Repository.repo_name.in_(repo_names)))
 

	
 
    for repo in repo_list:
 
        # update latest revision metadata in database
 
        repo.update_changeset_cache()
 
        # invalidate in-memory VCS object cache... will be repopulated on
 
        # first access
 
        repo.set_invalidate()
 

	
 
    Session().commit()
 

	
 
    click.echo('Updated database with information about latest change in the following %s repositories:' % (len(repo_list)))
 
    click.echo('\n'.join(repo.repo_name for repo in repo_list))
kallithea/lib/paster_commands/update_repoinfo.py
Show inline comments
 
deleted file
setup.py
Show inline comments
 
@@ -166,7 +166,6 @@ setuptools.setup(
 
    make-index=kallithea.lib.paster_commands.make_index:Command
 
    make-rcext=kallithea.lib.paster_commands.make_rcextensions:Command
 
    setup-db=kallithea.lib.paster_commands.setup_db:Command
 
    update-repoinfo=kallithea.lib.paster_commands.update_repoinfo:Command
 
    upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
 
    """,
 
)
0 comments (0 inline, 0 general)