| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e4ed59a commit 8e29a91
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,7 +119,7 @@ def _get_commit(self): | |||
| 119 | 119 | # Otherwise it would have detached it | |
| 120 | 120 | if tokens[0] != "ref:": | |
| 121 | 121 | raise ValueError("Failed to parse symbolic refernce: wanted 'ref: <hexsha>', got %r" % value) | |
| 122 | - return Head(self.repo, tokens[1]).commit | ||
| 122 | + return Reference.from_path(self.repo, tokens[1]).commit | ||
| 123 | 123 | ||
| 124 | 124 | def _set_commit(self, commit): | |
| 125 | 125 | """ | |
@@ -149,13 +149,13 @@ def _get_reference(self): | |||
| 149 | 149 | ||
| 150 | 150 | def _set_reference(self, ref): | |
| 151 | 151 | """ | |
| 152 | - Set ourselves to the given ref. It will stay a symbol if the ref is a Head. | ||
| 152 | + Set ourselves to the given ref. It will stay a symbol if the ref is a Reference. | ||
| 153 | 153 | Otherwise we try to get a commit from it using our interface. | |
| 154 | 154 | ||
| 155 | 155 | Strings are allowed but will be checked to be sure we have a commit | |
| 156 | 156 | """ | |
| 157 | 157 | write_value = None | |
| 158 | - if isinstance(ref, Head): | ||
| 158 | + if isinstance(ref, SymbolicReference): | ||
| 159 | 159 | write_value = "ref: %s" % ref.path | |
| 160 | 160 | elif isinstance(ref, Commit): | |
| 161 | 161 | write_value = ref.sha | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,20 +89,28 @@ def test_head_reset(self, rw_repo): | |||
| 89 | 89 | for head in heads: | |
| 90 | 90 | cur_head.reference = head | |
| 91 | 91 | assert cur_head.reference == head | |
| 92 | + assert isinstance(cur_head.reference, Head) | ||
| 92 | 93 | assert cur_head.commit == head.commit | |
| 93 | 94 | assert not cur_head.is_detached | |
| 94 | 95 | # END for each head | |
| 95 | 96 | ||
| 96 | 97 | # detach | |
| 97 | - cur_head.reference = heads[0].commit | ||
| 98 | - assert cur_head.commit == heads[0].commit | ||
| 98 | + active_head = heads[0] | ||
| 99 | + curhead_commit = active_head.commit | ||
| 100 | + cur_head.reference = curhead_commit | ||
| 101 | + assert cur_head.commit == curhead_commit | ||
| 99 | 102 | assert cur_head.is_detached | |
| 100 | 103 | self.failUnlessRaises(TypeError, getattr, cur_head, "reference") | |
| 101 | 104 | ||
| 105 | + # tags are references, hence we can point to them | ||
| 102 | 106 | some_tag = rw_repo.tags[0] | |
| 103 | 107 | cur_head.reference = some_tag | |
| 104 | - assert cur_head.is_detached | ||
| 108 | + assert not cur_head.is_detached | ||
| 105 | 109 | assert cur_head.commit == some_tag.commit | |
| 110 | + assert isinstance(cur_head.reference, TagReference) | ||
| 111 | + | ||
| 112 | + # put HEAD back to a real head, otherwise everything else fails | ||
| 113 | + cur_head.reference = active_head | ||
| 106 | 114 | ||
| 107 | 115 | # type check | |
| 108 | 116 | self.failUnlessRaises(ValueError, setattr, cur_head, "reference", "that") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments