diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2014-11-19 11:42:01 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2014-11-19 11:44:55 +0100 |
commit | 7ea782803efe1974471430d70ee19419287fd3d0 (patch) | |
tree | 906861d83a594e75198627b253d3f50697415b7a | |
parent | d48ed95cc7bd2ad0ac36593bb2440f24f675eb59 (diff) | |
parent | 3621c06c3173bff395645bd416f0efafa20a1da6 (diff) | |
download | gitpython-7ea782803efe1974471430d70ee19419287fd3d0.tar.gz |
Merge branch 'feature/0.3/git-file-support' of https://github.com/igetgames/GitPython into igetgames-feature/0.3/git-file-support
Using the previous implementation of read_gitfile, but added the previously missing test from this PR.
Conflicts:
git/repo/base.py
git/test/test_repo.py
-rw-r--r-- | git/test/fixtures/git_file | 1 | ||||
-rw-r--r-- | git/test/test_repo.py | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/git/test/fixtures/git_file b/git/test/fixtures/git_file new file mode 100644 index 00000000..2efda9f5 --- /dev/null +++ b/git/test/fixtures/git_file @@ -0,0 +1 @@ +gitdir: ./.real diff --git a/git/test/test_repo.py b/git/test/test_repo.py index d6568d0b..83bcdcbe 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -24,7 +24,6 @@ from cStringIO import StringIO class TestRepo(TestBase): - @raises(InvalidGitRepositoryError) def test_new_should_raise_on_invalid_repo_location(self): Repo(tempfile.gettempdir()) @@ -615,3 +614,20 @@ class TestRepo(TestBase): assert isinstance(sm, Submodule) # note: the rest of this functionality is tested in test_submodule + + @with_rw_repo('HEAD') + def test_git_file(self, rwrepo): + # Move the .git directory to another location and create the .git file. + real_path_abs = os.path.abspath(join_path_native(rwrepo.working_tree_dir, '.real')) + os.rename(rwrepo.git_dir, real_path_abs) + git_file_path = join_path_native(rwrepo.working_tree_dir, '.git') + open(git_file_path, 'wb').write(fixture('git_file')) + + # Create a repo and make sure it's pointing to the relocated .git directory. + git_file_repo = Repo(rwrepo.working_tree_dir) + assert os.path.abspath(git_file_repo.git_dir) == real_path_abs + + # Test using an absolute gitdir path in the .git file. + open(git_file_path, 'wb').write('gitdir: %s\n' % real_path_abs) + git_file_repo = Repo(rwrepo.working_tree_dir) + assert os.path.abspath(git_file_repo.git_dir) == real_path_abs |