* Move named file initilization to BaseRepo. (Dave Borowitz)
+ * Add logging utilities and git/HTTP server logging. (Dave Borowitz)
+
+ * The GitClient interface has been cleaned up and instances are now reusable.
+ (Augie Fackler)
+
++ * Allow overriding paths to executables in GitSSHClient.
++ (Ross Light, Jelmer Vernooij, #585204)
++
TESTS
* Add tests for sorted_tree_items and C implementation. (Dave Borowitz)
self.host = host
self.port = port
self.username = username
- self.receive_pack_path = "git-receive-pack"
- self.upload_pack_path = "git-upload-pack"
- self._args = args
- self._kwargs = kwargs
+ GitClient.__init__(self, *args, **kwargs)
++ self.alternative_paths = {}
+
- def send_pack(self, path, determine_wants, generate_pack_contents):
- remote = get_ssh_vendor().connect_ssh(
- self.host, ["'%s' '%s'" % (self.receive_pack_path, path)],
- port=self.port, username=self.username)
- client = GitClient(lambda: _fileno_can_read(remote.proc.stdout.fileno()), remote.recv, remote.send, *self._args, **self._kwargs)
- return client.send_pack(path, determine_wants, generate_pack_contents)
++ def _get_cmd_path(self, cmd):
++ return self.alternative_paths.get(cmd, 'git-%s' % cmd)
- def fetch_pack(self, path, determine_wants, graph_walker, pack_data,
- progress):
- remote = get_ssh_vendor().connect_ssh(
- self.host, ["'%s' '%s'" % (self.upload_pack_path, path)],
+ def _connect(self, cmd, path):
+ con = get_ssh_vendor().connect_ssh(
- self.host, ["%s '%s'" % ('git-' + cmd, path)],
++ self.host, ["%s '%s'" % (self._get_cmd_path(cmd), path)],
port=self.port, username=self.username)
- client = GitClient(lambda: _fileno_can_read(remote.proc.stdout.fileno()), remote.recv, remote.send, *self._args, **self._kwargs)
- return client.fetch_pack(path, determine_wants, graph_walker, pack_data,
- progress)
+ return Protocol(con.read, con.write), con.can_read
def get_transport_and_path(uri):
from dulwich.client import (
GitClient,
++ SSHGitClient,
)
+from dulwich.tests import (
+ TestCase,
+ )
+from dulwich.protocol import (
+ Protocol,
+ )
+
+
+class DummyClient(GitClient):
+ def __init__(self, can_read, read, write):
+ self.can_read = can_read
+ self.read = read
+ self.write = write
+ GitClient.__init__(self)
+
+ def _connect(self, service, path):
+ return Protocol(self.read, self.write), self.can_read
# TODO(durin42): add unit-level tests of GitClient
self.rin.seek(0)
self.client.fetch_pack("bla", lambda heads: [], None, None, None)
self.assertEquals(self.rout.getvalue(), "0000")
++
++
++class SSHGitClientTests(TestCase):
++
++ def setUp(self):
++ super(SSHGitClientTests, self).setUp()
++ self.client = SSHGitClient("git.samba.org")
++
++ def test_default_command(self):
++ self.assertEquals("git-upload-pack", self.client._get_cmd_path("upload-pack"))
++
++ def test_alternative_command_path(self):
++ self.client.alternative_paths["upload-pack"] = "/usr/lib/git/git-upload-pack"
++ self.assertEquals("/usr/lib/git/git-upload-pack", self.client._get_cmd_path("upload-pack"))
++