File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ gitdir: ./.real
Original file line number Diff line number Diff line change 2424
2525
2626class TestRepo (TestBase ):
27-
2827 @raises (InvalidGitRepositoryError )
2928 def test_new_should_raise_on_invalid_repo_location (self ):
3029 Repo (tempfile .gettempdir ())
@@ -615,3 +614,20 @@ def test_submodule_update(self, rwrepo):
615614 assert isinstance (sm , Submodule )
616615
617616 # note: the rest of this functionality is tested in test_submodule
617+
618+ @with_rw_repo ('HEAD' )
619+ def test_git_file (self , rwrepo ):
620+ # Move the .git directory to another location and create the .git file.
621+ real_path_abs = os .path .abspath (join_path_native (rwrepo .working_tree_dir , '.real' ))
622+ os .rename (rwrepo .git_dir , real_path_abs )
623+ git_file_path = join_path_native (rwrepo .working_tree_dir , '.git' )
624+ open (git_file_path , 'wb' ).write (fixture ('git_file' ))
625+
626+ # Create a repo and make sure it's pointing to the relocated .git directory.
627+ git_file_repo = Repo (rwrepo .working_tree_dir )
628+ assert os .path .abspath (git_file_repo .git_dir ) == real_path_abs
629+
630+ # Test using an absolute gitdir path in the .git file.
631+ open (git_file_path , 'wb' ).write ('gitdir: %s\n ' % real_path_abs )
632+ git_file_repo = Repo (rwrepo .working_tree_dir )
633+ assert os .path .abspath (git_file_repo .git_dir ) == real_path_abs
You can’t perform that action at this time.
0 commit comments