Ejemplo n.º 1
0
def test_existing_git_repo(tmpdir):
    repo_folder = Path(str(tmpdir)) / "repos" / "squid" / ".git"
    repo_folder.mkdir(parents=True, exist_ok=True)

    r = Repo(
        url="https://github.com/tekulvw/Squid-Plugins",
        name="squid",
        branch="rewrite_cogs",
        folder_path=repo_folder.parent,
    )

    exists, _ = r._existing_git_repo()

    assert exists is True
Ejemplo n.º 2
0
def test_existing_git_repo(tmp_path):
    repo_folder = tmp_path / "repos" / "squid" / ".git"
    repo_folder.mkdir(parents=True, exist_ok=True)

    r = Repo(
        url="https://github.com/tekulvw/Squid-Plugins",
        name="squid",
        branch="rewrite_cogs",
        commit="6acb5decbb717932e5dc0cda7fca0eff452c47dd",
        folder_path=repo_folder.parent,
    )

    exists, git_path = r._existing_git_repo()

    assert exists is True
    assert git_path == repo_folder
Ejemplo n.º 3
0
def bot_repo(event_loop):
    cwd = Path.cwd()
    return Repo(
        name="Red-DiscordBot",
        branch="WRONG",
        url="https://empty.com/something.git",
        folder_path=cwd,
        loop=event_loop,
    )
Ejemplo n.º 4
0
def repo(tmpdir):
    repo_folder = Path(str(tmpdir)) / "repos" / "squid"
    repo_folder.mkdir(parents=True, exist_ok=True)

    return Repo(
        url="https://github.com/tekulvw/Squid-Plugins",
        name="squid",
        branch="rewrite_cogs",
        folder_path=repo_folder,
    )
Ejemplo n.º 5
0
def repo(tmp_path):
    repo_folder = tmp_path / "repos" / "squid"
    repo_folder.mkdir(parents=True, exist_ok=True)

    return Repo(
        url="https://github.com/tekulvw/Squid-Plugins",
        name="squid",
        branch="rewrite_cogs",
        commit="6acb5decbb717932e5dc0cda7fca0eff452c47dd",
        folder_path=repo_folder,
    )
Ejemplo n.º 6
0
async def git_repo(_session_git_repo, tmp_path, event_loop):
    # fixture only copies repo that was imported in _session_git_repo
    repo_path = tmp_path / "redbot-testrepo"
    shutil.copytree(_session_git_repo.folder_path, repo_path)
    repo = Repo(
        name="redbot-testrepo",
        url=_session_git_repo.url,
        branch=_session_git_repo.branch,
        commit=_session_git_repo.commit,
        folder_path=repo_path,
    )
    return repo
Ejemplo n.º 7
0
async def git_repo_with_remote(git_repo, tmp_path, event_loop):
    # this can safely be used when you want to do changes to origin repo
    repo_path = tmp_path / "redbot-testrepo_with_remote"
    repo = Repo(
        name="redbot-testrepo",
        url=str(git_repo.folder_path),
        branch=git_repo.branch,
        commit=git_repo.commit,
        folder_path=repo_path,
    )
    sp.run(("git", "clone", str(git_repo.folder_path), str(repo_path)), check=True)
    return repo
Ejemplo n.º 8
0
async def cloned_git_repo(_session_git_repo, tmp_path, event_loop):
    # don't use this if you want to edit origin repo
    repo_path = tmp_path / "redbot-cloned_testrepo"
    repo = Repo(
        name="redbot-testrepo",
        url=str(_session_git_repo.folder_path),
        branch=_session_git_repo.branch,
        commit=_session_git_repo.commit,
        folder_path=repo_path,
    )
    sp.run(("git", "clone", str(_session_git_repo.folder_path), str(repo_path)), check=True)
    return repo
Ejemplo n.º 9
0
async def _session_git_repo(tmp_path_factory, event_loop):
    # we will import repo only once once per session and duplicate the repo folder
    repo_path = tmp_path_factory.mktemp("session_git_repo")
    repo = Repo(name="redbot-testrepo", url="", branch="master", commit="", folder_path=repo_path)
    git_dirparams = _init_test_repo(repo_path)
    fast_import = sp.Popen((*git_dirparams, "fast-import", "--quiet"), stdin=sp.PIPE)
    with TEST_REPO_EXPORT_PTH.open(mode="rb") as f:
        fast_import.communicate(f.read())
    return_code = fast_import.wait()
    if return_code:
        raise Exception(f"git fast-import failed with code {return_code}")
    sp.run((*git_dirparams, "reset", "--hard"))
    return repo