コード例 #1
0
ファイル: test_git.py プロジェクト: dmusican/repobee
def test_clone_single_raises_on_non_zero_exit_from_git_pull(env_setup, mocker):
    stderr = b"This is pretty bad!"
    # already patched in env_setup fixture
    subprocess.run.return_value = RunTuple(1, "", stderr)

    with pytest.raises(exception.CloneFailedError) as exc:
        git.clone_single(f"{URL_TEMPLATE.format('')}")
    assert "Failed to clone" in str(exc.value)
コード例 #2
0
ファイル: test_git.py プロジェクト: repobee/repobee
def test_clone_single_issues_correct_command_with_defaults(env_setup):
    expected_command = (
        f"git clone --single-branch {env_setup.expected_url}".split())

    git.clone_single(URL_TEMPLATE.format(""))
    subprocess.run.assert_any_call(
        expected_command,
        cwd=".",
        capture_output=True,
    )
コード例 #3
0
ファイル: test_git.py プロジェクト: repobee/repobee
def test_clone_single_issues_correct_command_with_cwd(env_setup):
    working_dir = "some/working/dir"
    branch = "other-branch"
    expected_command = (
        f"git clone --single-branch {env_setup.expected_url} {branch}".split())

    git.clone_single(URL_TEMPLATE.format(""), branch=branch, cwd=working_dir)
    subprocess.run.assert_called_once_with(
        expected_command,
        cwd=str(working_dir),
        capture_output=True,
    )
コード例 #4
0
ファイル: test_git.py プロジェクト: repobee/repobee
def test_clone_single_issues_correct_command_non_default_branch(env_setup):
    branch = "other-branch"
    expected_command = (
        f"git clone --single-branch {env_setup.expected_url} {branch}".split())

    git.clone_single(URL_TEMPLATE.format(""), branch=branch)

    subprocess.run.assert_any_call(
        expected_command,
        cwd=".",
        capture_output=True,
    )
コード例 #5
0
def _clone_all(
    repos: Iterable[plug.TemplateRepo],
    cwd: pathlib.Path,
    api: plug.PlatformAPI,
):
    """Attempts to clone all repos sequentially.

    Args:
        repos: Repos to clone.
        cwd: Working directory. Use temporary directory for automatic cleanup.
        api: An instance of the platform API.
    """
    try:
        for repo in plug.cli.io.progress_bar(
                repos, desc="Cloning template repositories", unit="repos"):
            url = _try_insert_auth(repo, api)
            plug.log.info(f"Cloning into '{url}'")
            git.clone_single(url, cwd=str(cwd))
    except exception.CloneFailedError:
        plug.log.error(f"Error cloning into {url}, aborting ...")
        raise