diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 23:31:26 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 23:31:26 +0200 |
commit | b7a5c05875a760c0bf83af6617c68061bda6cfc5 (patch) | |
tree | cf2090d419ff714b4e1293523cf1568bc2331855 | |
parent | 58e2157ad3aa9d75ef4abb90eb2d1f01fba0ba2b (diff) | |
download | gitpython-b7a5c05875a760c0bf83af6617c68061bda6cfc5.tar.gz |
Adjusted tests to deal with API changes
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | lib/git/refs.py | 7 | ||||
-rw-r--r-- | test/git/test_index.py | 4 | ||||
-rw-r--r-- | test/git/test_refs.py | 12 | ||||
-rw-r--r-- | test/git/test_repo.py | 10 |
5 files changed, 15 insertions, 20 deletions
@@ -64,6 +64,8 @@ Refs a symbolic reference anymore. Currently, we cannot handle this that well as we do not check for this case. This should be added though as it is valid to have a detached head in some cases. +* Allow to set SymbolicReferences to a specific Head Reference. This is like + a git-reset --soft Remote ------ diff --git a/lib/git/refs.py b/lib/git/refs.py index 97d0a6eb..aeee0da1 100644 --- a/lib/git/refs.py +++ b/lib/git/refs.py @@ -222,7 +222,7 @@ class SymbolicReference(object): """ fp = open(os.path.join(self.repo.path, self.name), 'r') try: - tokens = fp.readline().split(' ') + tokens = fp.readline().rstrip().split(' ') if tokens[0] != 'ref:': raise TypeError("%s is a detached symbolic reference as it points to %r" % tokens[0]) return Reference.from_path(self.repo, tokens[1]) @@ -298,10 +298,9 @@ class HEAD(SymbolicReference): raise ValueError( "Cannot reset the working tree if the index is not reset as well") # END working tree handling - repo.git.reset(mode, commit, paths, **kwargs) + self.repo.git.reset(mode, commit, paths, **kwargs) - # we always point to the active branch as it is the one changing - self + return self class Head(Reference): diff --git a/test/git/test_index.py b/test/git/test_index.py index 257acf10..7bc2ad7e 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -116,8 +116,8 @@ class TestTree(TestBase): # test diff # resetting the head will leave the index in a different state, and the # diff will yield a few changes - cur_head_commit = rw_repo.head.commit - ref = rw_repo.head.reset(rw_repo, 'HEAD~6', index=True, working_tree=False) + cur_head_commit = rw_repo.head.reference.commit + ref = rw_repo.head.reset('HEAD~6', index=True, working_tree=False) # diff against same index is 0 diff = index.diff() diff --git a/test/git/test_refs.py b/test/git/test_refs.py index ece6bf3e..0954d42d 100644 --- a/test/git/test_refs.py +++ b/test/git/test_refs.py @@ -72,13 +72,13 @@ class TestRefs(TestBase): def test_head_reset(self, rw_repo): cur_head = rw_repo.head new_head_commit = cur_head.ref.commit.parents[0] - reset_head = Head.reset(rw_repo, new_head_commit, index=True) # index only - assert reset_head.commit == new_head_commit + cur_head.reset(new_head_commit, index=True) # index only + assert cur_head.reference.commit == new_head_commit - self.failUnlessRaises(ValueError, Head.reset, rw_repo, new_head_commit, index=False, working_tree=True) + self.failUnlessRaises(ValueError, cur_head.reset, new_head_commit, index=False, working_tree=True) new_head_commit = new_head_commit.parents[0] - reset_head = Head.reset(rw_repo, new_head_commit, index=True, working_tree=True) # index + wt - assert reset_head.commit == new_head_commit + cur_head.reset(new_head_commit, index=True, working_tree=True) # index + wt + assert cur_head.reference.commit == new_head_commit # paths - Head.reset(rw_repo, new_head_commit, paths = "lib") + cur_head.reset(new_head_commit, paths = "lib") diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 02eea7de..b02610f4 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -168,17 +168,11 @@ class TestRepo(TestBase): self.rorepo._bare = True assert self.rorepo.is_dirty == False - @patch_object(Git, '_call_process') - def test_active_branch(self, git): - git.return_value = 'refs/heads/major-refactoring' - assert_equal(self.rorepo.active_branch.name, 'major-refactoring') - assert_equal(git.call_args, (('symbolic_ref', 'HEAD'), {})) - def test_head(self): - assert self.rorepo.head.object == self.rorepo.active_branch.object + assert self.rorepo.head.reference.object == self.rorepo.active_branch.object def test_tag(self): - assert self.rorepo.tag('0.1.5').commit + assert self.rorepo.tag('refs/tags/0.1.5').commit def test_archive(self): tmpfile = os.tmpfile() |