diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-26 11:49:58 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-26 12:09:23 +0100 |
commit | aaeb986f3a09c1353bdf50ab23cca8c53c397831 (patch) | |
tree | 6f0575dab0a2cd04558d854cc62d99e1fe93bd0f /test/git/test_refs.py | |
parent | 9c92df685d6c600a0a3324dff08a4d00d829a4f5 (diff) | |
download | gitpython-aaeb986f3a09c1353bdf50ab23cca8c53c397831.tar.gz |
SymbolicReferences can now be at any path within the repository, there is no restriction anymore.
Added a test to assure the git commands can handle it
Diffstat (limited to 'test/git/test_refs.py')
-rw-r--r-- | test/git/test_refs.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/test/git/test_refs.py b/test/git/test_refs.py index 8fa30aa1..1eceb162 100644 --- a/test/git/test_refs.py +++ b/test/git/test_refs.py @@ -10,6 +10,7 @@ from git import * import git.refs as refs from git.objects.tag import TagObject from itertools import chain +import os class TestRefs(TestBase): @@ -63,7 +64,7 @@ class TestRefs(TestBase): types_found = set() for ref in self.rorepo.refs: types_found.add(type(ref)) - assert len(types_found) == 3 + assert len(types_found) == 4 @with_rw_repo('0.1.6') def test_head_reset(self, rw_repo): @@ -233,7 +234,30 @@ class TestRefs(TestBase): self.failUnlessRaises(GitCommandError, far_away_head.checkout) assert active_branch == active_branch.checkout(force=True) + # test symbolic references which are not at default locations like HEAD + # or FETCH_HEAD - they may also be at spots in refs of course + symbol_ref_path = "refs/symbol_ref" + symref = SymbolicReference(rw_repo, symbol_ref_path) + assert symref.path == symbol_ref_path + symbol_ref_abspath = os.path.join(rw_repo.path, symref.path) + + # set it + symref.reference = new_head + assert symref.reference == new_head + assert os.path.isfile(symbol_ref_abspath) + assert symref.commit == new_head.commit + # test ref listing - assure we have packed refs - rw_repo.git.pack_refs(all=True) - assert rw_repo.heads + rw_repo.git.pack_refs(all=True, prune=True) + heads = rw_repo.heads + assert heads + assert new_head in heads + assert active_branch in heads assert rw_repo.tags + + # NOTE: It appears git-cat-file cannot resolve refs which are packed ! + # At least it fails here for some reason + # Couldn't reproduce the bug in a simple example though ... lets see. + self.failUnlessRaises(ValueError, getattr, new_head, 'commit') + self.failUnlessRaises(ValueError, getattr, symref, "commit") + |