Просмотр исходного кода

Fix SSH connections with custom ssh command

Regression from 0b0fed6e

Fixes #1945
Jelmer Vernooij 3 месяцев назад
Родитель
Сommit
f188122e77
4 измененных файлов с 22 добавлено и 0 удалено
  1. 3 0
      NEWS
  2. 1 0
      dulwich/client.py
  3. 1 0
      tests/compat/test_client.py
  4. 17 0
      tests/test_client.py

+ 3 - 0
NEWS

@@ -5,6 +5,9 @@
    collapse operations, and the 'sdir' extension.
    (Jelmer Vernooij, #1797)
 
+ * Fix passing ssh_command, password, and key_filename parameters to the SSH
+   vendor. Regression from 0.24.2.  (Jelmer Vernooij, #1945)
+
 0.24.6	2025-10-19
 
  * Fix import failure when ``sys.stdin`` is ``None``. The ``dulwich.server``

+ 1 - 0
dulwich/client.py

@@ -3128,6 +3128,7 @@ class SSHGitClient(TraditionalGitClient):
             port=self.port,
             username=self.username,
             protocol_version=protocol_version,
+            **kwargs,
         )
         return (
             Protocol(

+ 1 - 0
tests/compat/test_client.py

@@ -580,6 +580,7 @@ class TestSSHVendor:
         port=None,
         password=None,
         key_filename=None,
+        ssh_command=None,
         protocol_version=None,
     ):
         # Handle both bytes and string commands

+ 17 - 0
tests/test_client.py

@@ -1025,6 +1025,23 @@ class SSHGitClientTests(TestCase):
         test_client = SSHGitClient("git.samba.org", config=config)
         self.assertEqual(test_client.ssh_command, "/usr/bin/ssh -v")
 
+    def test_ssh_kwargs_passed_to_vendor(self) -> None:
+        # Test that ssh_command and other kwargs are actually passed to the SSH vendor
+        server = self.server
+        client = self.client
+
+        # Set custom ssh_command
+        client.ssh_command = "custom-ssh-wrapper.sh -o Option=Value"
+        client.password = "test-password"
+        client.key_filename = "/path/to/key"
+
+        # Connect and verify all kwargs are passed through
+        client._connect(b"upload-pack", b"/path/to/repo")
+
+        self.assertEqual(server.ssh_command, "custom-ssh-wrapper.sh -o Option=Value")
+        self.assertEqual(server.password, "test-password")
+        self.assertEqual(server.key_filename, "/path/to/key")
+
 
 class ReportStatusParserTests(TestCase):
     def test_invalid_pack(self) -> None: