示例#1
0
文件: git.py 项目: robmadole/lure
def clone(location):
    """
    Clone a Git repository if it doesn't exist into a temporary directory.

    :param str location: the Git URL to clone
    :rtype: pygit2.Repository
    """
    path = join(config.CLONE_ROOT, _simple_location_name(location))

    log.info('Cloning to path {}'.format(path))

    try:
        log.info('Looking for existing repository')
        repository_path = discover_repository(path)
    except KeyError:
        log.info('No existing repository found, cloning fresh')
        return clone_repository(location, path)
    else:
        log.info('Repository already exists at {}'.format(repository_path))
        repository = Repository(repository_path)

        remote = repository.remotes[0]
        remote.sideband_progress = log.info

        log.info('Fetching to get the latest objects from remote')
        remote.fetch()

        return repository
示例#2
0
文件: runner.py 项目: robmadole/lure
def languages():
    output = []
    for language, versions in helpers.languages().items():
        output.append('{!r}'.format(language))
        output.extend(['   {}'.format(i) for i in versions])

    log.info(block_format('Listing languages available', '\n'.join(output)))
示例#3
0
def _run(arguments):
    spec_filename = arguments['<lurespec>']

    try:
        log.info('Loading the specifications file')
        spec = load_from_file(spec_filename)
    except SpecNotFound as snf:
        log.critical(snf)
        return
    except BadSpecSyntax as bss:
        log.critical(bss)
        return
    else:
        run_spec(spec)
示例#4
0
文件: runner.py 项目: robmadole/lure
def run_spec(spec):
    repository = clone(spec.repository)

    install_jig_plugin(repository, spec.plugin)

    editor = shebang_editor(spec, find_plugin_pre_commit_script(repository))

    original_shebang = next(editor)

    log.info('Running automated tests that are bundled with the plugin')
    log.info('Original shebang on the plugin is {}'.format(original_shebang))

    for state in editor:
        log.info('Modifying the pre-commit to use {} {}'.format(*state))

    log.info('Restored plugin pre-commit script to the original state')
示例#5
0
文件: jig.py 项目: robmadole/lure
def install_jig_plugin(repository, plugin):
    """
    Initialize a repository for Jig and install a single plugin.

    :param pygit2.Repository repository: the Git repository
    :param str plugin: the URL to a Jig plugin that will be passed to ``jig
        plugin add``
    """
    log.info('Initialize repository to use Jig')
    try:
        check_output(
            [config.JIG_SCRIPT, 'init', repository.workdir],
            stderr=STDOUT
        )
    except CalledProcessError as cpe:
        if not isdir(join(repository.workdir, config.JIG_INIT_DIRECTORY)):
            log.error(block_format(
                'Unable to init repository for use with Jig',
                cpe.output.decode('utf8')
            ))

    log.info('Installing Jig plugin {}'.format(plugin))
    try:
        check_output(
            [config.JIG_SCRIPT, 'plugin', 'add', '-r', repository.workdir, plugin],
            stderr=STDOUT
        )
    except CalledProcessError as cpe:
        if not 'already installed' in cpe.output.decode('utf8'):
            log.error(block_format(
                'Unable to install the plugin in {}'.format(repository.workdir),
                cpe.output.decode('utf8')
            ))
            return False

    return True