Repo.clone_from localhost #1493
Replies: 2 comments
-
This looks like the server should support the dumb http protocol which requires a little more than hosting a git repository via http. I assume the repository is available on the same machine so it's fine to specify a local filesystem path as url. To see if it works, I suggest to use the git command-line rather than GitPython for less convoluted error reporting. |
Beta Was this translation helpful? Give feedback.
-
This worked,
though it kind of fails to test what really will happens in the real case (the function to test works on a gitlab repository - using the ssh protocol) I went to the git page to read about this dumb protocol, but I am not sure how to implement it...my server class and instance look like this, class Server(Thread):
def __init__(self, directory):
super().__init__()
self.event = Event()
handler = partial(SimpleHTTPRequestHandler, directory=directory)
self.httpd = HTTPServer(("", 0), handler)
self.url = f"http://localhost:{self.httpd.server_port}"
self.httpd.timeout = 0.1
self.httpd.handle_timeout = lambda: None
def run(self):
with self.httpd:
while not self.event.is_set():
self.httpd.handle_request() @pytest.fixture(scope="module")
def server(server_tmp_path):
s = Server(server_tmp_path)
s.start()
try:
yield s
finally:
s.event.set()
s.join() |
Beta Was this translation helpful? Give feedback.
-
Within a
pytest
suite I have created aServer(Thread)
class and aserver_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,
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,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,
I get the following Traceback,
Any idea what could be the problem?
Beta Was this translation helpful? Give feedback.
All reactions