|
36 | 36 | __all__ = ["SymbolicReference"]
|
37 | 37 |
|
38 | 38 |
|
39 |
| -def _git_dir(repo: 'Repo', path: Union[PathLike, None]) -> PathLike: |
| 39 | +def _git_dir(repo: 'Repo', path: PathLike) -> PathLike: |
40 | 40 | """ Find the git dir that's appropriate for the path"""
|
41 | 41 | name = f"{path}"
|
42 | 42 | if name in ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'index', 'logs']:
|
@@ -136,27 +136,26 @@ def _iter_packed_refs(cls, repo: 'Repo') -> Iterator[Tuple[str, str]]:
|
136 | 136 | # alright.
|
137 | 137 |
|
138 | 138 | @classmethod
|
139 |
| - def dereference_recursive(cls, repo: 'Repo', ref_path: Union[None, PathLike]) -> str: |
| 139 | + def dereference_recursive(cls, repo: 'Repo', ref_path: PathLike) -> str: |
140 | 140 | """
|
141 | 141 | :return: hexsha stored in the reference at the given ref_path, recursively dereferencing all
|
142 | 142 | intermediate references as required
|
143 | 143 | :param repo: the repository containing the reference at ref_path"""
|
144 |
| - while True: # loop that overwrites ref_path each loop |
| 144 | + while True: |
145 | 145 | hexsha, ref_path = cls._get_ref_info(repo, ref_path)
|
146 | 146 | if hexsha is not None:
|
147 | 147 | return hexsha
|
148 | 148 | # END recursive dereferencing
|
149 | 149 |
|
150 | 150 | @classmethod
|
151 |
| - def _get_ref_info_helper(cls, repo: 'Repo', ref_path: Union[PathLike, None] |
152 |
| - ) -> Union[Tuple[str, None], Tuple[None, str]]: |
| 151 | + def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike): |
153 | 152 | """Return: (str(sha), str(target_ref_path)) if available, the sha the file at
|
154 | 153 | rela_path points to, or None. target_ref_path is the reference we
|
155 | 154 | point to, or None"""
|
156 | 155 | tokens: Union[None, List[str], Tuple[str, str]] = None
|
157 | 156 | repodir = _git_dir(repo, ref_path)
|
158 | 157 | try:
|
159 |
| - with open(os.path.join(repodir, cast(str, ref_path)), 'rt', encoding='UTF-8') as fp: |
| 158 | + with open(os.path.join(repodir, ref_path), 'rt', encoding='UTF-8') as fp: |
160 | 159 | value = fp.read().rstrip()
|
161 | 160 | # Don't only split on spaces, but on whitespace, which allows to parse lines like
|
162 | 161 | # 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo
|
@@ -188,7 +187,7 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: Union[PathLike, None]
|
188 | 187 | raise ValueError("Failed to parse reference information from %r" % ref_path)
|
189 | 188 |
|
190 | 189 | @classmethod
|
191 |
| - def _get_ref_info(cls, repo: 'Repo', ref_path: Union[PathLike, None]) -> Union[Tuple[str, None], Tuple[None, str]]: |
| 190 | + def _get_ref_info(cls, repo, ref_path): |
192 | 191 | """Return: (str(sha), str(target_ref_path)) if available, the sha the file at
|
193 | 192 | rela_path points to, or None. target_ref_path is the reference we
|
194 | 193 | point to, or None"""
|
|
0 commit comments