Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3347c00
change ordereddict guard, add type: ignore
Yobmod Jul 28, 2021
77a7769
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Jul 28, 2021
28fdd30
Fix SymbolicReference reference typing
Yobmod Jul 28, 2021
3abc837
Add another type ignore for Ordereddict
Yobmod Jul 28, 2021
6791424
Rmv py 3.10 check for typing.Ordereddict - its deprecated then, but w…
Yobmod Jul 28, 2021
c464e33
Fix some SymbolicReference types
Yobmod Jul 28, 2021
7cf30c1
Fix forwardref
Yobmod Jul 28, 2021
5b880c0
Fix more missing types in Symbolic.py
Yobmod Jul 28, 2021
07d71e5
Fix more missing types in Symbolic.py
Yobmod Jul 28, 2021
b8b07b9
Fix more missing types in Symbolic.py.
Yobmod Jul 28, 2021
390efbf
Fix more missing types in Symbolic.py, cos GuthubActions pytest stuck
Yobmod Jul 28, 2021
070f5c0
Rmv test file
Yobmod Jul 28, 2021
adc00dd
Fix more missing types in Symbolic.py, cos GuthubActions pytest stuck
Yobmod Jul 28, 2021
28251c3
Try downgrading pip
Yobmod Jul 28, 2021
dbb689b
its not pip...
Yobmod Jul 28, 2021
cf29514
try https://github.com/actions/virtual-environments/issues/709 workar…
Yobmod Jul 28, 2021
f1e6e8d
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Jul 31, 2021
15d1c01
Add type to symbolicreference.name()
Yobmod Jul 31, 2021
34e9850
Add type to symbolicreference.iter_items()
Yobmod Jul 31, 2021
265d40b
Add type to symbolicreference.rename()
Yobmod Jul 31, 2021
bdd6a43
Add type to symbolicreference.__repr__()
Yobmod Jul 31, 2021
1f92267
Add type to symbolicreference._get_ref_info()
Yobmod Jul 31, 2021
ad4517f
Add type to symbolicreference._get_packed_refs_path()
Yobmod Jul 31, 2021
6b0faba
Add type to symbolicreference.dereference_recursive()
Yobmod Jul 31, 2021
7e972b9
Add type to symbolicreference.dereference_recursive()
Yobmod Jul 31, 2021
24c1242
Add type to symbolicreference()
Yobmod Jul 31, 2021
8eedc9d
Add type to symbolicreference.get_()
Yobmod Jul 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add type to symbolicreference.get_()
  • Loading branch information
Yobmod committed Jul 31, 2021
commit 8eedc9d002da9bb085be4a82ffb5372f8f8ff7a2
13 changes: 6 additions & 7 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
__all__ = ["SymbolicReference"]


def _git_dir(repo: 'Repo', path: Union[PathLike, None]) -> PathLike:
def _git_dir(repo: 'Repo', path: PathLike) -> PathLike:
""" Find the git dir that's appropriate for the path"""
name = f"{path}"
if name in ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'index', 'logs']:
Expand Down Expand Up @@ -136,27 +136,26 @@ def _iter_packed_refs(cls, repo: 'Repo') -> Iterator[Tuple[str, str]]:
# alright.

@classmethod
def dereference_recursive(cls, repo: 'Repo', ref_path: Union[None, PathLike]) -> str:
def dereference_recursive(cls, repo: 'Repo', ref_path: PathLike) -> str:
"""
:return: hexsha stored in the reference at the given ref_path, recursively dereferencing all
intermediate references as required
:param repo: the repository containing the reference at ref_path"""
while True: # loop that overwrites ref_path each loop
while True:
hexsha, ref_path = cls._get_ref_info(repo, ref_path)
if hexsha is not None:
return hexsha
# END recursive dereferencing

@classmethod
def _get_ref_info_helper(cls, repo: 'Repo', ref_path: Union[PathLike, None]
) -> Union[Tuple[str, None], Tuple[None, str]]:
def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike):
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None. target_ref_path is the reference we
point to, or None"""
tokens: Union[None, List[str], Tuple[str, str]] = None
repodir = _git_dir(repo, ref_path)
try:
with open(os.path.join(repodir, cast(str, ref_path)), 'rt', encoding='UTF-8') as fp:
with open(os.path.join(repodir, ref_path), 'rt', encoding='UTF-8') as fp:
value = fp.read().rstrip()
# Don't only split on spaces, but on whitespace, which allows to parse lines like
# 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo
Expand Down Expand Up @@ -188,7 +187,7 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: Union[PathLike, None]
raise ValueError("Failed to parse reference information from %r" % ref_path)

@classmethod
def _get_ref_info(cls, repo: 'Repo', ref_path: Union[PathLike, None]) -> Union[Tuple[str, None], Tuple[None, str]]:
def _get_ref_info(cls, repo, ref_path):
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None. target_ref_path is the reference we
point to, or None"""
Expand Down