예제 #1
0
파일: parsing.py 프로젝트: tohanss/repobee
def _repo_names_to_urls(repo_names: Iterable[str], org_name: str,
                        api: plug.PlatformAPI) -> Tuple[List[str], List[str]]:
    """Use the repo_names to extract urls to the repos. Look for git
    repos with the correct names in the local directory and create local uris
    for them.  For the rest, create urls to the repos assuming they are in the
    target organization. Do note that there is _no_ guarantee that the remote
    repos exist as checking this takes too much time with the REST API.

    A possible improvement would be to use the GraphQL API for this function.

    Args:
        repo_names: names of repositories.
        org_name: Name of the organization these repos are expected in.
        api: An API instance.
    Returns:
        A tuple of lists with (non_local_urls, local_uris).
    Raises:
        ParseError: If local templates are found, but allow_local is False.
    """
    local = [
        name for name in repo_names if util.is_git_repo(os.path.abspath(name))
    ]

    non_local = [name for name in repo_names if name not in local]

    non_local_urls = api.get_repo_urls(non_local, org_name)
    local_uris = [
        pathlib.Path(os.path.abspath(repo_name)).as_uri()
        for repo_name in local
    ]
    return non_local_urls, local_uris
예제 #2
0
파일: git.py 프로젝트: dmusican/repobee
def _ensure_repo_dir_exists(clone_spec: CloneSpec) -> None:
    """Checks if a dir for the repo url exists, and if it does not, creates it.
    Also initializez (or reinitializes, if it alrady exists) as a git repo.
    """
    if not clone_spec.dest.exists():
        clone_spec.dest.mkdir(parents=True)
    if not util.is_git_repo(str(clone_spec.dest)):
        _git_init(clone_spec.dest)
예제 #3
0
파일: repos.py 프로젝트: dmusican/repobee
def _check_for_non_git_dir_path_clashes(repos: List[plug.StudentRepo]) -> None:
    """Raise if any of the student repo paths clash with a non-git
    directory.
    """
    for repo in repos:
        if repo.path.exists() and not util.is_git_repo(repo.path):
            raise exception.RepoBeeException(
                f"name clash with directory that is not a Git repository: "
                f"'{repo.path}'")