Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Repo.clone_from localhost #1492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HealthyPear opened this issue Sep 13, 2022 · 0 comments
Closed

Repo.clone_from localhost #1492

HealthyPear opened this issue Sep 13, 2022 · 0 comments

Comments

@HealthyPear
Copy link

Within a pytest suite I have created a Server(Thread) class and a server_tmp_path factory in order to simulate the download of a git repository in my project (actually I might need to download only a specific file, but I have to download the whole repo first, am I right?).

I create the test repo like this,

@pytest.fixture(scope="module")
def test_git_repo(server_tmp_path):
    """Initialize a dummy git repository"""
    import git

    repo_dir = server_tmp_path / "test_git_repo"
    file_name = "test_file.txt"
    file_name_2 = "test_file_2.txt"

    r = git.Repo.init(repo_dir)
    Path(repo_dir / file_name).touch()
    Path(repo_dir / file_name_2).touch()
    r.index.add([file_name])
    r.index.add([file_name_2])
    r.index.commit("initial commit")

    return repo_dir

and then I define the test function as test_download_git_repo(server, test_git_repo, tmp_path) so then from inside I can retrieve the URL of the test repo (e.g. http://localhost:51848/test_git_repo/) and see that the stuff is there,

image

When I cd the directory I can see that it corresponds to an initialized git repository with 1 main branch and the initial commit.

So I am a bit baffled that when I try to do the following,

path = tmp_path / test_git_repo.name
git.repo.Repo.clone_from(f"{server.url}/{test_git_repo.name}", path)

I get the following Traceback,

127.0.0.1 - - [13/Sep/2022 18:07:34] code 404, message File not found
127.0.0.1 - - [13/Sep/2022 18:07:34] "GET /test_git_repo/info/refs?service=git-upload-pack HTTP/1.1" 404 -
*** git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v http://localhost:51848/test_git_repo /private/var/folders/2z/142033n17rbfy969s6h4hymw0000gn/T/pytest-of-michele/pytest-27/test_download_git_repo0/test_git_repo
  stderr: 'Cloning into '/private/var/folders/2z/142033n17rbfy969s6h4hymw0000gn/T/pytest-of-michele/pytest-27/test_download_git_repo0/test_git_repo'...
fatal: repository 'http://localhost:51848/test_git_repo/' not found

Any idea what could be the problem?

@gitpython-developers gitpython-developers locked and limited conversation to collaborators Sep 14, 2022
@Byron Byron converted this issue into discussion #1493 Sep 14, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Development

No branches or pull requests

1 participant