test_client.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. # test_client.py -- Tests for the git protocol, client side
  2. # Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; version 2
  7. # or (at your option) any later version of the License.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. # MA 02110-1301, USA.
  18. from io import BytesIO
  19. import sys
  20. try:
  21. from unittest import skipIf
  22. except ImportError:
  23. from unittest2 import skipIf
  24. from dulwich import (
  25. client,
  26. )
  27. from dulwich.client import (
  28. LocalGitClient,
  29. TraditionalGitClient,
  30. TCPGitClient,
  31. SubprocessGitClient,
  32. SSHGitClient,
  33. HttpGitClient,
  34. ReportStatusParser,
  35. SendPackError,
  36. UpdateRefsError,
  37. get_transport_and_path,
  38. get_transport_and_path_from_url,
  39. )
  40. from dulwich.tests import (
  41. TestCase,
  42. )
  43. from dulwich.protocol import (
  44. TCP_GIT_PORT,
  45. Protocol,
  46. )
  47. from dulwich.pack import (
  48. write_pack_objects,
  49. )
  50. from dulwich.objects import (
  51. Commit,
  52. Tree
  53. )
  54. from dulwich.repo import MemoryRepo
  55. from dulwich.tests.utils import (
  56. open_repo,
  57. )
  58. class DummyClient(TraditionalGitClient):
  59. def __init__(self, can_read, read, write):
  60. self.can_read = can_read
  61. self.read = read
  62. self.write = write
  63. TraditionalGitClient.__init__(self)
  64. def _connect(self, service, path):
  65. return Protocol(self.read, self.write), self.can_read
  66. # TODO(durin42): add unit-level tests of GitClient
  67. class GitClientTests(TestCase):
  68. def setUp(self):
  69. super(GitClientTests, self).setUp()
  70. self.rout = BytesIO()
  71. self.rin = BytesIO()
  72. self.client = DummyClient(lambda x: True, self.rin.read,
  73. self.rout.write)
  74. def test_caps(self):
  75. self.assertEqual(set(['multi_ack', 'side-band-64k', 'ofs-delta',
  76. 'thin-pack', 'multi_ack_detailed']),
  77. set(self.client._fetch_capabilities))
  78. self.assertEqual(set(['ofs-delta', 'report-status', 'side-band-64k']),
  79. set(self.client._send_capabilities))
  80. def test_archive_ack(self):
  81. self.rin.write(
  82. '0009NACK\n'
  83. '0000')
  84. self.rin.seek(0)
  85. self.client.archive('bla', 'HEAD', None, None)
  86. self.assertEqual(self.rout.getvalue(), '0011argument HEAD0000')
  87. def test_fetch_empty(self):
  88. self.rin.write('0000')
  89. self.rin.seek(0)
  90. self.client.fetch_pack('/', lambda heads: [], None, None)
  91. def test_fetch_pack_none(self):
  92. self.rin.write(
  93. '008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack '
  94. 'thin-pack side-band side-band-64k ofs-delta shallow no-progress '
  95. 'include-tag\n'
  96. '0000')
  97. self.rin.seek(0)
  98. self.client.fetch_pack('bla', lambda heads: [], None, None, None)
  99. self.assertEqual(self.rout.getvalue(), '0000')
  100. def test_send_pack_no_sideband64k_with_update_ref_error(self):
  101. # No side-bank-64k reported by server shouldn't try to parse
  102. # side band data
  103. pkts = ['55dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 capabilities^{}'
  104. '\x00 report-status delete-refs ofs-delta\n',
  105. '',
  106. "unpack ok",
  107. "ng refs/foo/bar pre-receive hook declined",
  108. '']
  109. for pkt in pkts:
  110. if pkt == '':
  111. self.rin.write("0000")
  112. else:
  113. self.rin.write("%04x%s" % (len(pkt)+4, pkt))
  114. self.rin.seek(0)
  115. tree = Tree()
  116. commit = Commit()
  117. commit.tree = tree
  118. commit.parents = []
  119. commit.author = commit.committer = 'test user'
  120. commit.commit_time = commit.author_time = 1174773719
  121. commit.commit_timezone = commit.author_timezone = 0
  122. commit.encoding = 'UTF-8'
  123. commit.message = 'test message'
  124. def determine_wants(refs):
  125. return {'refs/foo/bar': commit.id, }
  126. def generate_pack_contents(have, want):
  127. return [(commit, None), (tree, ''), ]
  128. self.assertRaises(UpdateRefsError,
  129. self.client.send_pack, "blah",
  130. determine_wants, generate_pack_contents)
  131. def test_send_pack_none(self):
  132. self.rin.write(
  133. '0078310ca9477129b8586fa2afc779c1f57cf64bba6c '
  134. 'refs/heads/master\x00 report-status delete-refs '
  135. 'side-band-64k quiet ofs-delta\n'
  136. '0000')
  137. self.rin.seek(0)
  138. def determine_wants(refs):
  139. return {
  140. 'refs/heads/master': '310ca9477129b8586fa2afc779c1f57cf64bba6c'
  141. }
  142. def generate_pack_contents(have, want):
  143. return {}
  144. self.client.send_pack('/', determine_wants, generate_pack_contents)
  145. self.assertEqual(self.rout.getvalue(), '0000')
  146. def test_send_pack_delete_only(self):
  147. self.rin.write(
  148. '0063310ca9477129b8586fa2afc779c1f57cf64bba6c '
  149. 'refs/heads/master\x00report-status delete-refs ofs-delta\n'
  150. '0000000eunpack ok\n'
  151. '0019ok refs/heads/master\n'
  152. '0000')
  153. self.rin.seek(0)
  154. def determine_wants(refs):
  155. return {'refs/heads/master': '0' * 40}
  156. def generate_pack_contents(have, want):
  157. return {}
  158. self.client.send_pack('/', determine_wants, generate_pack_contents)
  159. self.assertIn(
  160. self.rout.getvalue(),
  161. ['007f310ca9477129b8586fa2afc779c1f57cf64bba6c '
  162. '0000000000000000000000000000000000000000 '
  163. 'refs/heads/master\x00report-status ofs-delta0000',
  164. '007f310ca9477129b8586fa2afc779c1f57cf64bba6c '
  165. '0000000000000000000000000000000000000000 '
  166. 'refs/heads/master\x00ofs-delta report-status0000'])
  167. def test_send_pack_new_ref_only(self):
  168. self.rin.write(
  169. '0063310ca9477129b8586fa2afc779c1f57cf64bba6c '
  170. 'refs/heads/master\x00report-status delete-refs ofs-delta\n'
  171. '0000000eunpack ok\n'
  172. '0019ok refs/heads/blah12\n'
  173. '0000')
  174. self.rin.seek(0)
  175. def determine_wants(refs):
  176. return {
  177. 'refs/heads/blah12':
  178. '310ca9477129b8586fa2afc779c1f57cf64bba6c',
  179. 'refs/heads/master': '310ca9477129b8586fa2afc779c1f57cf64bba6c'
  180. }
  181. def generate_pack_contents(have, want):
  182. return {}
  183. f = BytesIO()
  184. write_pack_objects(f, {})
  185. self.client.send_pack('/', determine_wants, generate_pack_contents)
  186. self.assertIn(
  187. self.rout.getvalue(),
  188. ['007f0000000000000000000000000000000000000000 '
  189. '310ca9477129b8586fa2afc779c1f57cf64bba6c '
  190. 'refs/heads/blah12\x00report-status ofs-delta0000%s'
  191. % f.getvalue(),
  192. '007f0000000000000000000000000000000000000000 '
  193. '310ca9477129b8586fa2afc779c1f57cf64bba6c '
  194. 'refs/heads/blah12\x00ofs-delta report-status0000%s'
  195. % f.getvalue()])
  196. def test_send_pack_new_ref(self):
  197. self.rin.write(
  198. '0064310ca9477129b8586fa2afc779c1f57cf64bba6c '
  199. 'refs/heads/master\x00 report-status delete-refs ofs-delta\n'
  200. '0000000eunpack ok\n'
  201. '0019ok refs/heads/blah12\n'
  202. '0000')
  203. self.rin.seek(0)
  204. tree = Tree()
  205. commit = Commit()
  206. commit.tree = tree
  207. commit.parents = []
  208. commit.author = commit.committer = 'test user'
  209. commit.commit_time = commit.author_time = 1174773719
  210. commit.commit_timezone = commit.author_timezone = 0
  211. commit.encoding = 'UTF-8'
  212. commit.message = 'test message'
  213. def determine_wants(refs):
  214. return {
  215. 'refs/heads/blah12': commit.id,
  216. 'refs/heads/master': '310ca9477129b8586fa2afc779c1f57cf64bba6c'
  217. }
  218. def generate_pack_contents(have, want):
  219. return [(commit, None), (tree, ''), ]
  220. f = BytesIO()
  221. write_pack_objects(f, generate_pack_contents(None, None))
  222. self.client.send_pack('/', determine_wants, generate_pack_contents)
  223. self.assertIn(
  224. self.rout.getvalue(),
  225. ['007f0000000000000000000000000000000000000000 %s '
  226. 'refs/heads/blah12\x00report-status ofs-delta0000%s'
  227. % (commit.id, f.getvalue()),
  228. '007f0000000000000000000000000000000000000000 %s '
  229. 'refs/heads/blah12\x00ofs-delta report-status0000%s'
  230. % (commit.id, f.getvalue())])
  231. def test_send_pack_no_deleteref_delete_only(self):
  232. pkts = ['310ca9477129b8586fa2afc779c1f57cf64bba6c refs/heads/master'
  233. '\x00 report-status ofs-delta\n',
  234. '',
  235. '']
  236. for pkt in pkts:
  237. if pkt == '':
  238. self.rin.write("0000")
  239. else:
  240. self.rin.write("%04x%s" % (len(pkt)+4, pkt))
  241. self.rin.seek(0)
  242. def determine_wants(refs):
  243. return {'refs/heads/master': '0' * 40}
  244. def generate_pack_contents(have, want):
  245. return {}
  246. self.assertRaises(UpdateRefsError,
  247. self.client.send_pack, "/",
  248. determine_wants, generate_pack_contents)
  249. self.assertEqual(self.rout.getvalue(), '0000')
  250. class TestGetTransportAndPath(TestCase):
  251. def test_tcp(self):
  252. c, path = get_transport_and_path('git://foo.com/bar/baz')
  253. self.assertTrue(isinstance(c, TCPGitClient))
  254. self.assertEqual('foo.com', c._host)
  255. self.assertEqual(TCP_GIT_PORT, c._port)
  256. self.assertEqual('/bar/baz', path)
  257. def test_tcp_port(self):
  258. c, path = get_transport_and_path('git://foo.com:1234/bar/baz')
  259. self.assertTrue(isinstance(c, TCPGitClient))
  260. self.assertEqual('foo.com', c._host)
  261. self.assertEqual(1234, c._port)
  262. self.assertEqual('/bar/baz', path)
  263. def test_ssh_explicit(self):
  264. c, path = get_transport_and_path('git+ssh://foo.com/bar/baz')
  265. self.assertTrue(isinstance(c, SSHGitClient))
  266. self.assertEqual('foo.com', c.host)
  267. self.assertEqual(None, c.port)
  268. self.assertEqual(None, c.username)
  269. self.assertEqual('bar/baz', path)
  270. def test_ssh_port_explicit(self):
  271. c, path = get_transport_and_path(
  272. 'git+ssh://foo.com:1234/bar/baz')
  273. self.assertTrue(isinstance(c, SSHGitClient))
  274. self.assertEqual('foo.com', c.host)
  275. self.assertEqual(1234, c.port)
  276. self.assertEqual('bar/baz', path)
  277. def test_ssh_abspath_explicit(self):
  278. c, path = get_transport_and_path('git+ssh://foo.com//bar/baz')
  279. self.assertTrue(isinstance(c, SSHGitClient))
  280. self.assertEqual('foo.com', c.host)
  281. self.assertEqual(None, c.port)
  282. self.assertEqual(None, c.username)
  283. self.assertEqual('/bar/baz', path)
  284. def test_ssh_port_abspath_explicit(self):
  285. c, path = get_transport_and_path(
  286. 'git+ssh://foo.com:1234//bar/baz')
  287. self.assertTrue(isinstance(c, SSHGitClient))
  288. self.assertEqual('foo.com', c.host)
  289. self.assertEqual(1234, c.port)
  290. self.assertEqual('/bar/baz', path)
  291. def test_ssh_implicit(self):
  292. c, path = get_transport_and_path('foo:/bar/baz')
  293. self.assertTrue(isinstance(c, SSHGitClient))
  294. self.assertEqual('foo', c.host)
  295. self.assertEqual(None, c.port)
  296. self.assertEqual(None, c.username)
  297. self.assertEqual('/bar/baz', path)
  298. def test_ssh_host(self):
  299. c, path = get_transport_and_path('foo.com:/bar/baz')
  300. self.assertTrue(isinstance(c, SSHGitClient))
  301. self.assertEqual('foo.com', c.host)
  302. self.assertEqual(None, c.port)
  303. self.assertEqual(None, c.username)
  304. self.assertEqual('/bar/baz', path)
  305. def test_ssh_user_host(self):
  306. c, path = get_transport_and_path('user@foo.com:/bar/baz')
  307. self.assertTrue(isinstance(c, SSHGitClient))
  308. self.assertEqual('foo.com', c.host)
  309. self.assertEqual(None, c.port)
  310. self.assertEqual('user', c.username)
  311. self.assertEqual('/bar/baz', path)
  312. def test_ssh_relpath(self):
  313. c, path = get_transport_and_path('foo:bar/baz')
  314. self.assertTrue(isinstance(c, SSHGitClient))
  315. self.assertEqual('foo', c.host)
  316. self.assertEqual(None, c.port)
  317. self.assertEqual(None, c.username)
  318. self.assertEqual('bar/baz', path)
  319. def test_ssh_host_relpath(self):
  320. c, path = get_transport_and_path('foo.com:bar/baz')
  321. self.assertTrue(isinstance(c, SSHGitClient))
  322. self.assertEqual('foo.com', c.host)
  323. self.assertEqual(None, c.port)
  324. self.assertEqual(None, c.username)
  325. self.assertEqual('bar/baz', path)
  326. def test_ssh_user_host_relpath(self):
  327. c, path = get_transport_and_path('user@foo.com:bar/baz')
  328. self.assertTrue(isinstance(c, SSHGitClient))
  329. self.assertEqual('foo.com', c.host)
  330. self.assertEqual(None, c.port)
  331. self.assertEqual('user', c.username)
  332. self.assertEqual('bar/baz', path)
  333. def test_subprocess(self):
  334. c, path = get_transport_and_path('foo.bar/baz')
  335. self.assertTrue(isinstance(c, SubprocessGitClient))
  336. self.assertEqual('foo.bar/baz', path)
  337. @skipIf(sys.platform != 'win32', 'Behaviour only happens on windows.')
  338. def test_local_abs_windows_path(self):
  339. c, path = get_transport_and_path('C:\\foo.bar\\baz')
  340. self.assertTrue(isinstance(c, SubprocessGitClient))
  341. self.assertEqual('C:\\foo.bar\\baz', path)
  342. def test_error(self):
  343. # Need to use a known urlparse.uses_netloc URL scheme to get the
  344. # expected parsing of the URL on Python versions less than 2.6.5
  345. c, path = get_transport_and_path('prospero://bar/baz')
  346. self.assertTrue(isinstance(c, SSHGitClient))
  347. def test_http(self):
  348. url = 'https://github.com/jelmer/dulwich'
  349. c, path = get_transport_and_path(url)
  350. self.assertTrue(isinstance(c, HttpGitClient))
  351. self.assertEqual('/jelmer/dulwich', path)
  352. class TestGetTransportAndPathFromUrl(TestCase):
  353. def test_tcp(self):
  354. c, path = get_transport_and_path_from_url('git://foo.com/bar/baz')
  355. self.assertTrue(isinstance(c, TCPGitClient))
  356. self.assertEqual('foo.com', c._host)
  357. self.assertEqual(TCP_GIT_PORT, c._port)
  358. self.assertEqual('/bar/baz', path)
  359. def test_tcp_port(self):
  360. c, path = get_transport_and_path_from_url('git://foo.com:1234/bar/baz')
  361. self.assertTrue(isinstance(c, TCPGitClient))
  362. self.assertEqual('foo.com', c._host)
  363. self.assertEqual(1234, c._port)
  364. self.assertEqual('/bar/baz', path)
  365. def test_ssh_explicit(self):
  366. c, path = get_transport_and_path_from_url('git+ssh://foo.com/bar/baz')
  367. self.assertTrue(isinstance(c, SSHGitClient))
  368. self.assertEqual('foo.com', c.host)
  369. self.assertEqual(None, c.port)
  370. self.assertEqual(None, c.username)
  371. self.assertEqual('bar/baz', path)
  372. def test_ssh_port_explicit(self):
  373. c, path = get_transport_and_path_from_url(
  374. 'git+ssh://foo.com:1234/bar/baz')
  375. self.assertTrue(isinstance(c, SSHGitClient))
  376. self.assertEqual('foo.com', c.host)
  377. self.assertEqual(1234, c.port)
  378. self.assertEqual('bar/baz', path)
  379. def test_ssh_abspath_explicit(self):
  380. c, path = get_transport_and_path_from_url('git+ssh://foo.com//bar/baz')
  381. self.assertTrue(isinstance(c, SSHGitClient))
  382. self.assertEqual('foo.com', c.host)
  383. self.assertEqual(None, c.port)
  384. self.assertEqual(None, c.username)
  385. self.assertEqual('/bar/baz', path)
  386. def test_ssh_port_abspath_explicit(self):
  387. c, path = get_transport_and_path_from_url(
  388. 'git+ssh://foo.com:1234//bar/baz')
  389. self.assertTrue(isinstance(c, SSHGitClient))
  390. self.assertEqual('foo.com', c.host)
  391. self.assertEqual(1234, c.port)
  392. self.assertEqual('/bar/baz', path)
  393. def test_ssh_host_relpath(self):
  394. self.assertRaises(ValueError, get_transport_and_path_from_url,
  395. 'foo.com:bar/baz')
  396. def test_ssh_user_host_relpath(self):
  397. self.assertRaises(ValueError, get_transport_and_path_from_url,
  398. 'user@foo.com:bar/baz')
  399. def test_local_path(self):
  400. self.assertRaises(ValueError, get_transport_and_path_from_url,
  401. 'foo.bar/baz')
  402. def test_error(self):
  403. # Need to use a known urlparse.uses_netloc URL scheme to get the
  404. # expected parsing of the URL on Python versions less than 2.6.5
  405. self.assertRaises(ValueError, get_transport_and_path_from_url,
  406. 'prospero://bar/baz')
  407. def test_http(self):
  408. url = 'https://github.com/jelmer/dulwich'
  409. c, path = get_transport_and_path_from_url(url)
  410. self.assertTrue(isinstance(c, HttpGitClient))
  411. self.assertEqual('/jelmer/dulwich', path)
  412. def test_file(self):
  413. c, path = get_transport_and_path_from_url('file:///home/jelmer/foo')
  414. self.assertTrue(isinstance(c, SubprocessGitClient))
  415. self.assertEqual('/home/jelmer/foo', path)
  416. class TestSSHVendor(object):
  417. def __init__(self):
  418. self.host = None
  419. self.command = ""
  420. self.username = None
  421. self.port = None
  422. def run_command(self, host, command, username=None, port=None):
  423. self.host = host
  424. self.command = command
  425. self.username = username
  426. self.port = port
  427. class Subprocess: pass
  428. setattr(Subprocess, 'read', lambda: None)
  429. setattr(Subprocess, 'write', lambda: None)
  430. setattr(Subprocess, 'close', lambda: None)
  431. setattr(Subprocess, 'can_read', lambda: None)
  432. return Subprocess()
  433. class SSHGitClientTests(TestCase):
  434. def setUp(self):
  435. super(SSHGitClientTests, self).setUp()
  436. self.server = TestSSHVendor()
  437. self.real_vendor = client.get_ssh_vendor
  438. client.get_ssh_vendor = lambda: self.server
  439. self.client = SSHGitClient('git.samba.org')
  440. def tearDown(self):
  441. super(SSHGitClientTests, self).tearDown()
  442. client.get_ssh_vendor = self.real_vendor
  443. def test_default_command(self):
  444. self.assertEqual('git-upload-pack',
  445. self.client._get_cmd_path('upload-pack'))
  446. def test_alternative_command_path(self):
  447. self.client.alternative_paths['upload-pack'] = (
  448. '/usr/lib/git/git-upload-pack')
  449. self.assertEqual('/usr/lib/git/git-upload-pack',
  450. self.client._get_cmd_path('upload-pack'))
  451. def test_connect(self):
  452. server = self.server
  453. client = self.client
  454. client.username = "username"
  455. client.port = 1337
  456. client._connect("command", "/path/to/repo")
  457. self.assertEqual("username", server.username)
  458. self.assertEqual(1337, server.port)
  459. self.assertEqual(["git-command '/path/to/repo'"], server.command)
  460. client._connect("relative-command", "/~/path/to/repo")
  461. self.assertEqual(["git-relative-command '~/path/to/repo'"],
  462. server.command)
  463. class ReportStatusParserTests(TestCase):
  464. def test_invalid_pack(self):
  465. parser = ReportStatusParser()
  466. parser.handle_packet("unpack error - foo bar")
  467. parser.handle_packet("ok refs/foo/bar")
  468. parser.handle_packet(None)
  469. self.assertRaises(SendPackError, parser.check)
  470. def test_update_refs_error(self):
  471. parser = ReportStatusParser()
  472. parser.handle_packet("unpack ok")
  473. parser.handle_packet("ng refs/foo/bar need to pull")
  474. parser.handle_packet(None)
  475. self.assertRaises(UpdateRefsError, parser.check)
  476. def test_ok(self):
  477. parser = ReportStatusParser()
  478. parser.handle_packet("unpack ok")
  479. parser.handle_packet("ok refs/foo/bar")
  480. parser.handle_packet(None)
  481. parser.check()
  482. class LocalGitClientTests(TestCase):
  483. def test_fetch_into_empty(self):
  484. c = LocalGitClient()
  485. t = MemoryRepo()
  486. s = open_repo('a.git')
  487. self.assertEqual(s.get_refs(), c.fetch(s.path, t))
  488. def test_fetch_empty(self):
  489. c = LocalGitClient()
  490. s = open_repo('a.git')
  491. out = BytesIO()
  492. walker = {}
  493. c.fetch_pack(s.path, lambda heads: [], graph_walker=walker,
  494. pack_data=out.write)
  495. self.assertEqual("PACK\x00\x00\x00\x02\x00\x00\x00\x00\x02\x9d\x08"
  496. "\x82;\xd8\xa8\xea\xb5\x10\xadj\xc7\\\x82<\xfd>\xd3\x1e", out.getvalue())
  497. def test_fetch_pack_none(self):
  498. c = LocalGitClient()
  499. s = open_repo('a.git')
  500. out = BytesIO()
  501. walker = MemoryRepo().get_graph_walker()
  502. c.fetch_pack(s.path,
  503. lambda heads: ["a90fa2d900a17e99b433217e988c4eb4a2e9a097"],
  504. graph_walker=walker, pack_data=out.write)
  505. # Hardcoding is not ideal, but we'll fix that some other day..
  506. self.assertTrue(out.getvalue().startswith('PACK\x00\x00\x00\x02\x00\x00\x00\x07'))