| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -285,7 +285,7 @@ def set_object(self, object: Union[Commit_ish, 'SymbolicReference', str], logmsg | |||
| 285 | 285 | commit = property(_get_commit, set_commit, doc="Query or set commits directly") # type: ignore | |
| 286 | 286 | object = property(_get_object, set_object, doc="Return the object our ref currently refers to") # type: ignore | |
| 287 | 287 | ||
| 288 | - def _get_reference(self) -> 'Reference': | ||
| 288 | + def _get_reference(self) -> 'SymbolicReference': | ||
| 289 | 289 | """:return: Reference Object we point to | |
| 290 | 290 | :raise TypeError: If this symbolic reference is detached, hence it doesn't point | |
| 291 | 291 | to a reference, but to a commit""" | |
@@ -683,7 +683,7 @@ def iter_items(cls: Type[T_References], repo: 'Repo', common_path: Union[PathLik | |||
| 683 | 683 | return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached) | |
| 684 | 684 | ||
| 685 | 685 | @classmethod | |
| 686 | - def from_path(cls, repo: 'Repo', path: PathLike) -> Union['Head', 'TagReference', 'Reference']: | ||
| 686 | + def from_path(cls: Type[T_References], repo: 'Repo', path: PathLike) -> T_References: | ||
| 687 | 687 | """ | |
| 688 | 688 | :param path: full .git-directory-relative path name to the Reference to instantiate | |
| 689 | 689 | :note: use to_full_path() if you only have a partial path of a known Reference Type | |
@@ -698,12 +698,13 @@ def from_path(cls, repo: 'Repo', path: PathLike) -> Union['Head', 'TagReference' | |||
| 698 | 698 | from . import HEAD, Head, RemoteReference, TagReference, Reference | |
| 699 | 699 | for ref_type in (HEAD, Head, RemoteReference, TagReference, Reference, SymbolicReference): | |
| 700 | 700 | try: | |
| 701 | + instance: T_References | ||
| 701 | 702 | instance = ref_type(repo, path) | |
| 702 | 703 | if instance.__class__ == SymbolicReference and instance.is_detached: | |
| 703 | 704 | raise ValueError("SymbolRef was detached, we drop it") | |
| 704 | 705 | else: | |
| 705 | - assert isinstance(instance, Reference), "instance should be Reference or subtype" | ||
| 706 | 706 | return instance | |
| 707 | + | ||
| 707 | 708 | except ValueError: | |
| 708 | 709 | pass | |
| 709 | 710 | # END exception handling | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -632,7 +632,7 @@ def stale_refs(self) -> IterableList[Reference]: | |||
| 632 | 632 | as well. This is a fix for the issue described here: | |
| 633 | 633 | https://github.com/gitpython-developers/GitPython/issues/260 | |
| 634 | 634 | """ | |
| 635 | - out_refs: IterableList[RemoteReference] = IterableList(RemoteReference._id_attribute_, "%s/" % self.name) | ||
| 635 | + out_refs: IterableList[Reference] = IterableList(RemoteReference._id_attribute_, "%s/" % self.name) | ||
| 636 | 636 | for line in self.repo.git.remote("prune", "--dry-run", self).splitlines()[2:]: | |
| 637 | 637 | # expecting | |
| 638 | 638 | # * [would prune] origin/new_branch | |
@@ -642,7 +642,7 @@ def stale_refs(self) -> IterableList[Reference]: | |||
| 642 | 642 | ref_name = line.replace(token, "") | |
| 643 | 643 | # sometimes, paths start with a full ref name, like refs/tags/foo, see #260 | |
| 644 | 644 | if ref_name.startswith(Reference._common_path_default + '/'): | |
| 645 | - out_refs.append(SymbolicReference.from_path(self.repo, ref_name)) | ||
| 645 | + out_refs.append(Reference.from_path(self.repo, ref_name)) | ||
| 646 | 646 | else: | |
| 647 | 647 | fqhn = "%s/%s" % (RemoteReference._common_path_default, ref_name) | |
| 648 | 648 | out_refs.append(RemoteReference(self.repo, fqhn)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments