Skip to content
Snippets Groups Projects
clone_repos.py 711 B
Newer Older
""" Ensure that all repository are cloned and at their tip
"""
import hglib
from os.path import isdir, join
import yaml


def read_configuration(config_path):
    with open(config_path) as config_file:
        return yaml.load(config_file.read())


def clone_repositories(config, repos_dir):
    for repo_name, repo in config["repos"].items():
        clonedir = join(repos_dir, repo_name)
        if not isdir(clonedir):
            print("Cloning %s (%s) into %s" % (repo_name, repo["url"], clonedir))
            hglib.clone(repo["url"], clonedir)
        else:
            print("Repository %s is already cloned" % repo_name)


config = read_configuration("config.yaml")
clone_repositories(config, "repos")