i use git to remote data. This is my code.
from dulwich.repo import Repo
from dulwich.server import DictBackend, TCPGitServer
repo = dulwich.repo.Repo.init('remote', mkdir=True)
backend = DictBackend({'/': repo})
dul_server = TCPGitServer(backend, 'git://server.com/file.git', 0)
threading.Thread(target=dul_server.serve).start()
server_address, server_port = dul_server.socket.getsockname()
client = dulwich.client.TCPGitClient(server_address.encode('ascii'), server_port)
remote_refs = client.fetch('/', remote)
But I get the error:
socket.gaierror: [Errno -2] Name or service not known
What's my mistake?
Maybe I don't understand the api.
I want to execute git remote add -f origin <repo>
TCPGitServer doesn't take a URL but an address to listen on. You probably want something like this to start a server:
dul_server = TCPGitServer(backend, 'localhost', 0)