@@ -443,6 +443,17 @@ def test_clone_with_credentials(self):
443
443
444
444
self .assertFalse (repo .is_empty )
445
445
446
+ def test_clone_with_checkout_branch (self ):
447
+ # create a test case which isolates the remote
448
+ test_repo = clone_repository ('./test/data/testrepo.git' ,
449
+ os .path .join (self ._temp_dir , 'testrepo-orig.git' ),
450
+ bare = True )
451
+ test_repo .create_branch ('test' , test_repo [test_repo .head .target ])
452
+ repo = clone_repository (test_repo .path ,
453
+ os .path .join (self ._temp_dir , 'testrepo.git' ),
454
+ checkout_branch = 'test' , bare = True )
455
+ self .assertEqual (repo .lookup_reference ('HEAD' ).target , 'refs/heads/test' )
456
+
446
457
# FIXME The tests below are commented because they are broken:
447
458
#
448
459
# - test_clone_push_url: Passes, but does nothing useful.
@@ -452,8 +463,6 @@ def test_clone_with_credentials(self):
452
463
#
453
464
# - test_clone_push_spec: Passes, but does nothing useful.
454
465
#
455
- # - test_clone_checkout_branch: Fails, because the test fixture does not
456
- # have any branch named "test"
457
466
458
467
# def test_clone_push_url(self):
459
468
# repo_path = "./test/data/testrepo.git/"
@@ -485,15 +494,5 @@ def test_clone_with_credentials(self):
485
494
# # not sure how to test this either... couldn't find pushspec
486
495
# # self.assertEqual(repo.remotes[0].fetchspec, "refs/heads/test")
487
496
488
- # def test_clone_checkout_branch(self):
489
- # repo_path = "./test/data/testrepo.git/"
490
- # repo = clone_repository(repo_path, self._temp_dir,
491
- # checkout_branch="test")
492
- # self.assertFalse(repo.is_empty)
493
- # # FIXME: When pygit2 supports retrieving the current branch,
494
- # # enable this test
495
- # # self.assertEqual(repo.remotes[0].current_branch, "test")
496
-
497
-
498
497
if __name__ == '__main__' :
499
498
unittest .main ()
0 commit comments