|
29 | 29 | if sys.platform == "win32": |
30 | 30 | __all__.append("to_native_path_windows") |
31 | 31 |
|
32 | | -from abc import abstractmethod |
33 | 32 | import contextlib |
34 | | -from functools import wraps |
35 | 33 | import getpass |
36 | 34 | import logging |
37 | 35 | import ntpath |
38 | 36 | import os |
39 | 37 | import os.path as osp |
40 | | -from pathlib import Path |
41 | 38 | import platform |
42 | 39 | import re |
43 | 40 | import shutil |
44 | 41 | import stat |
45 | 42 | import subprocess |
46 | 43 | import time |
47 | | -from urllib.parse import urlsplit, urlunsplit |
48 | 44 | import warnings |
49 | | - |
50 | | -# NOTE: Unused imports can be improved now that CI testing has fully resumed. Some of |
51 | | -# these be used indirectly through other GitPython modules, which avoids having to write |
52 | | -# gitdb all the time in their imports. They are not in __all__, at least currently, |
53 | | -# because they could be removed or changed at any time, and so should not be considered |
54 | | -# conceptually public to code outside GitPython. Linters of course do not like it. |
55 | | -from gitdb.util import ( |
56 | | - LazyMixin, # noqa: F401 |
57 | | - LockedFD, # noqa: F401 |
58 | | - bin_to_hex, # noqa: F401 |
59 | | - file_contents_ro, # noqa: F401 |
60 | | - file_contents_ro_filepath, # noqa: F401 |
61 | | - hex_to_bin, # noqa: F401 |
62 | | - make_sha, |
63 | | - to_bin_sha, # noqa: F401 |
64 | | - to_hex_sha, # noqa: F401 |
65 | | -) |
| 45 | +from abc import abstractmethod |
| 46 | +from functools import wraps |
| 47 | +from pathlib import Path |
66 | 48 |
|
67 | 49 | # typing --------------------------------------------------------- |
68 | | - |
69 | 50 | from typing import ( |
| 51 | + IO, |
| 52 | + TYPE_CHECKING, |
70 | 53 | Any, |
71 | 54 | AnyStr, |
72 | 55 | Callable, |
73 | 56 | Dict, |
74 | 57 | Generator, |
75 | | - IO, |
76 | 58 | Iterator, |
77 | 59 | List, |
78 | 60 | Optional, |
79 | 61 | Pattern, |
80 | 62 | Sequence, |
81 | 63 | Tuple, |
82 | | - TYPE_CHECKING, |
83 | 64 | Type, |
84 | 65 | TypeVar, |
85 | 66 | Union, |
86 | 67 | cast, |
87 | 68 | overload, |
88 | 69 | ) |
| 70 | +from urllib.parse import urlsplit, urlunsplit |
| 71 | + |
| 72 | +# NOTE: Unused imports can be improved now that CI testing has fully resumed. Some of |
| 73 | +# these be used indirectly through other GitPython modules, which avoids having to write |
| 74 | +# gitdb all the time in their imports. They are not in __all__, at least currently, |
| 75 | +# because they could be removed or changed at any time, and so should not be considered |
| 76 | +# conceptually public to code outside GitPython. Linters of course do not like it. |
| 77 | +from gitdb.util import ( |
| 78 | + LazyMixin, # noqa: F401 |
| 79 | + LockedFD, # noqa: F401 |
| 80 | + bin_to_hex, # noqa: F401 |
| 81 | + file_contents_ro, # noqa: F401 |
| 82 | + file_contents_ro_filepath, # noqa: F401 |
| 83 | + hex_to_bin, # noqa: F401 |
| 84 | + make_sha, |
| 85 | + to_bin_sha, # noqa: F401 |
| 86 | + to_hex_sha, # noqa: F401 |
| 87 | +) |
89 | 88 |
|
90 | 89 | if TYPE_CHECKING: |
91 | 90 | from git.cmd import Git |
|
94 | 93 | from git.repo.base import Repo |
95 | 94 |
|
96 | 95 | from git.types import ( |
| 96 | + HSH_TD, |
97 | 97 | Files_TD, |
98 | 98 | Has_id_attribute, |
99 | | - HSH_TD, |
100 | 99 | Literal, |
101 | 100 | PathLike, |
102 | 101 | Protocol, |
@@ -419,11 +418,13 @@ def _validate_repo_path(path: PathLike, mode: Union[int, None] = None) -> None: |
419 | 418 | hfs_name = part.translate(_HFS_IGNORABLES).lower() |
420 | 419 | if ntfs_name in (".git", "git~1") or hfs_name == ".git": |
421 | 420 | raise ValueError("Repository path aliases Git metadata: %r" % name) |
422 | | - aliases_gitmodules = ( |
423 | | - ntfs_name == ".gitmodules" or hfs_name == ".gitmodules" or ntfs_name in _NTFS_DOTGITMODULES_SHORT_NAMES |
424 | | - ) |
425 | | - if aliases_gitmodules and mode is not None and stat.S_ISLNK(mode): |
426 | | - raise ValueError("Symbolic link aliases the submodule configuration: %r" % name) |
| 421 | + if mode is not None and stat.S_ISLNK(mode): |
| 422 | + if ( |
| 423 | + ntfs_name == ".gitmodules" |
| 424 | + or hfs_name == ".gitmodules" |
| 425 | + or ntfs_name in _NTFS_DOTGITMODULES_SHORT_NAMES |
| 426 | + ): |
| 427 | + raise ValueError("Symbolic link aliases the submodule configuration: %r" % name) |
427 | 428 |
|
428 | 429 |
|
429 | 430 | def assure_directory_exists(path: PathLike, is_file: bool = False) -> bool: |
|
0 commit comments