Procházet zdrojové kódy

Send agent= capability from client. (#298).

Jelmer Vernooij před 9 roky
rodič
revize
5591462981
3 změnil soubory, kde provedl 14 přidání a 3 odebrání
  1. 4 0
      NEWS
  2. 4 1
      dulwich/client.py
  3. 6 2
      dulwich/tests/test_client.py

+ 4 - 0
NEWS

@@ -1,5 +1,9 @@
 0.11.2	UNRELEASED
 
+ IMPROVEMENTS
+
+  * Add support for agent= capability. (Jelmer Vernooij, #298)
+
 0.11.1	2015-09-13
 
  Fix-up release to exclude broken blame.py file.

+ 4 - 1
dulwich/client.py

@@ -94,7 +94,10 @@ def _fileno_can_read(fileno):
     """Check if a file descriptor is readable."""
     return len(select.select([fileno], [], [], 0)[0]) > 0
 
-COMMON_CAPABILITIES = [CAPABILITY_OFS_DELTA, CAPABILITY_SIDE_BAND_64K]
+CAPABILITY_AGENT = ("agent=dulwich/%d.%d.%d" % dulwich.__version__).encode('ascii')
+
+COMMON_CAPABILITIES = [CAPABILITY_OFS_DELTA, CAPABILITY_SIDE_BAND_64K,
+                       CAPABILITY_AGENT]
 FETCH_CAPABILITIES = ([CAPABILITY_THIN_PACK, CAPABILITY_MULTI_ACK,
                        CAPABILITY_MULTI_ACK_DETAILED] +
                       COMMON_CAPABILITIES)

+ 6 - 2
dulwich/tests/test_client.py

@@ -23,6 +23,7 @@ import shutil
 import tempfile
 
 
+import dulwich
 from dulwich import (
     client,
     )
@@ -87,10 +88,13 @@ class GitClientTests(TestCase):
                                   self.rout.write)
 
     def test_caps(self):
+        agent_cap = ('agent=dulwich/%d.%d.%d' % dulwich.__version__).encode('ascii')
         self.assertEqual(set([b'multi_ack', b'side-band-64k', b'ofs-delta',
-                               b'thin-pack', b'multi_ack_detailed']),
+                               b'thin-pack', b'multi_ack_detailed',
+                               agent_cap]),
                           set(self.client._fetch_capabilities))
-        self.assertEqual(set([b'ofs-delta', b'report-status', b'side-band-64k']),
+        self.assertEqual(set([b'ofs-delta', b'report-status', b'side-band-64k',
+                              agent_cap]),
                           set(self.client._send_capabilities))
 
     def test_archive_ack(self):