Dulwich.io dulwich / acdc0ac
Cleanup directory after clone fails. Fixes #733. Jelmer Vernooij 2 months ago
3 changed file(s) with 10 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
99
1010 * Add a ``dulwich.porcelain.active_branch`` function.
1111 (Jelmer Vernooij)
12
13 * Cleanup new directory if clone fails. (Jelmer Vernooij, #733)
1214
1315 0.19.13 2019-08-19
1416
6464 import datetime
6565 import os
6666 import posixpath
67 import shutil
6768 import stat
6869 import sys
6970 import time
381382 errstream.write(b'Checking out ' + head.id + b'\n')
382383 r.reset_index(head.tree)
383384 except BaseException:
385 shutil.rmtree(target)
384386 r.close()
385387 raise
386388
349349 r = porcelain.clone(
350350 self.repo.path, target_path, checkout=True, errstream=errstream)
351351 r.close()
352
353 def test_source_broken(self):
354 target_path = tempfile.mkdtemp()
355 self.assertRaises(
356 Exception, porcelain.clone, '/nonexistant/repo', target_path)
357 self.assertFalse(os.path.exists(target_path))
352358
353359
354360 class InitTests(TestCase):