| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | """Package with general repository related functions""" | |
| 2 | - from git.refs.reference import Reference | ||
| 3 | - from git.types import Commit_ish | ||
| 2 | + from __future__ import annotations | ||
| 4 | 3 | import os | |
| 5 | 4 | import stat | |
| 6 | 5 | from string import digits | |
@@ -20,12 +19,13 @@ | |||
| 20 | 19 | # Typing ---------------------------------------------------------------------- | |
| 21 | 20 | ||
| 22 | 21 | from typing import Union, Optional, cast, TYPE_CHECKING | |
| 23 | - | ||
| 22 | + from git.types import Commit_ish | ||
| 24 | 23 | ||
| 25 | 24 | if TYPE_CHECKING: | |
| 26 | 25 | from git.types import PathLike | |
| 27 | 26 | from .base import Repo | |
| 28 | 27 | from git.db import GitCmdObjectDB | |
| 28 | + from git.refs.reference import Reference | ||
| 29 | 29 | from git.objects import Commit, TagObject, Blob, Tree | |
| 30 | 30 | from git.refs.tag import Tag | |
| 31 | 31 | ||
@@ -204,7 +204,7 @@ def rev_parse(repo: 'Repo', rev: str) -> Union['Commit', 'Tag', 'Tree', 'Blob']: | |||
| 204 | 204 | raise NotImplementedError("commit by message search ( regex )") | |
| 205 | 205 | # END handle search | |
| 206 | 206 | ||
| 207 | - obj: Union[Commit_ish, Reference, None] = None | ||
| 207 | + obj: Union[Commit_ish, 'Reference', None] = None | ||
| 208 | 208 | ref = None | |
| 209 | 209 | output_type = "commit" | |
| 210 | 210 | start = 0 | |
@@ -224,7 +224,7 @@ def rev_parse(repo: 'Repo', rev: str) -> Union['Commit', 'Tag', 'Tree', 'Blob']: | |||
| 224 | 224 | ref = repo.head.ref | |
| 225 | 225 | else: | |
| 226 | 226 | if token == '@': | |
| 227 | - ref = cast(Reference, name_to_object(repo, rev[:start], return_ref=True)) | ||
| 227 | + ref = cast('Reference', name_to_object(repo, rev[:start], return_ref=True)) | ||
| 228 | 228 | else: | |
| 229 | 229 | obj = cast(Commit_ish, name_to_object(repo, rev[:start])) | |
| 230 | 230 | # END handle token | |
@@ -251,13 +251,13 @@ def rev_parse(repo: 'Repo', rev: str) -> Union['Commit', 'Tag', 'Tree', 'Blob']: | |||
| 251 | 251 | pass # default | |
| 252 | 252 | elif output_type == 'tree': | |
| 253 | 253 | try: | |
| 254 | - obj = cast(Object, obj) | ||
| 254 | + obj = cast(Commit_ish, obj) | ||
| 255 | 255 | obj = to_commit(obj).tree | |
| 256 | 256 | except (AttributeError, ValueError): | |
| 257 | 257 | pass # error raised later | |
| 258 | 258 | # END exception handling | |
| 259 | 259 | elif output_type in ('', 'blob'): | |
| 260 | - obj = cast(TagObject, obj) | ||
| 260 | + obj = cast('TagObject', obj) | ||
| 261 | 261 | if obj and obj.type == 'tag': | |
| 262 | 262 | obj = deref_tag(obj) | |
| 263 | 263 | else: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments