| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 572ace0 commit 9b42689
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,15 +85,11 @@ Refs | |||
| 85 | 85 | handles symbolic refs as well as normal refs, updating the reflog if required. | |
| 86 | 86 | * I have read that refs can be symbolic refs as well which would imply the need | |
| 87 | 87 | to possibly dereference them. This makes sense as they originally where possibly | |
| 88 | - a symbolic link | ||
| 89 | - * Check whether we are the active reference HEAD.reference == this_ref | ||
| 90 | - - NO: The reference dosnt need to know - in fact it does not know about the | ||
| 91 | - main HEAD, so it may not use it. This is to be done in client code only. | ||
| 92 | - Remove me | ||
| 93 | - * Reference.from_path may return a symbolic reference although it is not related | ||
| 94 | - to the reference type. Split that up into two from_path on each of the types, | ||
| 95 | - and provide a general method outside of the type that tries both. | ||
| 96 | - * Making the reflog available might be useful actually. | ||
| 88 | + a symbolic link. This would mean References could be derived from SymbolicReference | ||
| 89 | + officially, but it would still be bad as not all References are symbolic ones. | ||
| 90 | + * Making the reflog available as command might be useful actually. This way historical | ||
| 91 | + references/commits can be returned. Git internally manages this if refs are specified | ||
| 92 | + with HEAD@{0} for instance | ||
| 97 | 93 | ||
| 98 | 94 | Remote | |
| 99 | 95 | ------ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,18 +151,12 @@ def iter_items(cls, repo, common_path = None, **kwargs): | |||
| 151 | 151 | def from_path(cls, repo, path): | |
| 152 | 152 | """ | |
| 153 | 153 | Return | |
| 154 | - Instance of type Reference, Head, Tag, SymbolicReference or HEAD | ||
| 154 | + Instance of type Reference, Head, or Tag | ||
| 155 | 155 | depending on the given path | |
| 156 | 156 | """ | |
| 157 | 157 | if not path: | |
| 158 | 158 | raise ValueError("Cannot create Reference from %r" % path) | |
| 159 | 159 | ||
| 160 | - if path == 'HEAD': | ||
| 161 | - return HEAD(repo, path) | ||
| 162 | - | ||
| 163 | - if '/' not in path: | ||
| 164 | - return SymbolicReference(repo, path) | ||
| 165 | - | ||
| 166 | 160 | for ref_type in (Head, RemoteReference, TagReference, Reference): | |
| 167 | 161 | try: | |
| 168 | 162 | return ref_type(repo, path) | |
@@ -218,7 +212,10 @@ class SymbolicReference(object): | |||
| 218 | 212 | ||
| 219 | 213 | def __init__(self, repo, name): | |
| 220 | 214 | if '/' in name: | |
| 215 | + # NOTE: Actually they can be looking like ordinary refs. Theoretically we handle this | ||
| 216 | + # case incorrectly | ||
| 221 | 217 | raise ValueError("SymbolicReferences are not located within a directory, got %s" % name) | |
| 218 | + # END error handling | ||
| 222 | 219 | self.repo = repo | |
| 223 | 220 | self.name = name | |
| 224 | 221 | ||
@@ -348,6 +345,23 @@ def is_detached(self): | |||
| 348 | 345 | except TypeError: | |
| 349 | 346 | return True | |
| 350 | 347 | ||
| 348 | + @classmethod | ||
| 349 | + def from_path(cls, repo, path): | ||
| 350 | + """ | ||
| 351 | + Return | ||
| 352 | + Instance of SymbolicReference or HEAD | ||
| 353 | + depending on the given path | ||
| 354 | + """ | ||
| 355 | + if not path: | ||
| 356 | + raise ValueError("Cannot create Symbolic Reference from %r" % path) | ||
| 357 | + | ||
| 358 | + if path == 'HEAD': | ||
| 359 | + return HEAD(repo, path) | ||
| 360 | + | ||
| 361 | + if '/' not in path: | ||
| 362 | + return SymbolicReference(repo, path) | ||
| 363 | + | ||
| 364 | + raise ValueError("Could not find symbolic reference type suitable to handle path %r" % path) | ||
| 351 | 365 | ||
| 352 | 366 | class HEAD(SymbolicReference): | |
| 353 | 367 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments