| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0414bf7 commit 3801505
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -652,14 +652,15 @@ def _to_relative_path(self, path: PathLike) -> PathLike: | |||
| 652 | 652 | ||
| 653 | 653 | :raise ValueError: | |
| 654 | 654 | """ | |
| 655 | + path = os.fspath(path) | ||
| 655 | 656 | if not osp.isabs(path): | |
| 656 | 657 | return path | |
| 657 | 658 | if self.repo.bare: | |
| 658 | 659 | raise InvalidGitRepositoryError("require non-bare repository") | |
| 659 | - if not osp.normpath(os.fspath(path)).startswith(os.fspath(self.repo.working_tree_dir)): | ||
| 660 | + if not osp.normpath(path).startswith(os.fspath(self.repo.working_tree_dir)): | ||
| 660 | 661 | raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir)) | |
| 661 | 662 | result = os.path.relpath(path, self.repo.working_tree_dir) | |
| 662 | - if os.fspath(path).endswith(os.sep) and not result.endswith(os.sep): | ||
| 663 | + if path.endswith(os.sep) and not result.endswith(os.sep): | ||
| 663 | 664 | result += os.sep | |
| 664 | 665 | return result | |
| 665 | 666 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,7 +37,7 @@ class TemporaryFileSwap: | |||
| 37 | 37 | __slots__ = ("file_path", "tmp_file_path") | |
| 38 | 38 | ||
| 39 | 39 | def __init__(self, file_path: PathLike) -> None: | |
| 40 | - self.file_path = file_path | ||
| 40 | + self.file_path = os.fspath(file_path) | ||
| 41 | 41 | dirname, basename = osp.split(file_path) | |
| 42 | 42 | fd, self.tmp_file_path = tempfile.mkstemp(prefix=basename, dir=dirname) | |
| 43 | 43 | os.close(fd) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | 9 | __all__ = ["HEAD", "Head"] | |
| 10 | 10 | ||
| 11 | + import os | ||
| 11 | 12 | from git.config import GitConfigParser, SectionConstraint | |
| 12 | 13 | from git.exc import GitCommandError | |
| 13 | 14 | from git.util import join_path | |
@@ -48,6 +49,7 @@ class HEAD(SymbolicReference): | |||
| 48 | 49 | commit: "Commit" | |
| 49 | 50 | ||
| 50 | 51 | def __init__(self, repo: "Repo", path: PathLike = _HEAD_NAME) -> None: | |
| 52 | + path = os.fspath(path) | ||
| 51 | 53 | if path != self._HEAD_NAME: | |
| 52 | 54 | raise ValueError("HEAD instance must point to %r, got %r" % (self._HEAD_NAME, path)) | |
| 53 | 55 | super().__init__(repo, path) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | __all__ = ["RefLog", "RefLogEntry"] | |
| 5 | 5 | ||
| 6 | 6 | from mmap import mmap | |
| 7 | + import os | ||
| 7 | 8 | import os.path as osp | |
| 8 | 9 | import re | |
| 9 | 10 | import time as _time | |
@@ -167,7 +168,7 @@ def __init__(self, filepath: Union[PathLike, None] = None) -> None: | |||
| 167 | 168 | """Initialize this instance with an optional filepath, from which we will | |
| 168 | 169 | initialize our data. The path is also used to write changes back using the | |
| 169 | 170 | :meth:`write` method.""" | |
| 170 | - self._path = filepath | ||
| 171 | + self._path = os.fspath(filepath) | ||
| 171 | 172 | if filepath is not None: | |
| 172 | 173 | self._read_from_file() | |
| 173 | 174 | # END handle filepath | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ class SymbolicReference: | |||
| 76 | 76 | ||
| 77 | 77 | def __init__(self, repo: "Repo", path: PathLike, check_path: bool = False) -> None: | |
| 78 | 78 | self.repo = repo | |
| 79 | - self.path = path | ||
| 79 | + self.path = os.fspath(path) | ||
| 80 | 80 | ||
| 81 | 81 | def __str__(self) -> str: | |
| 82 | 82 | return os.fspath(self.path) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,6 +62,7 @@ def is_git_dir(d: PathLike) -> bool: | |||
| 62 | 62 | clearly indicates that we don't support it. There is the unlikely danger to | |
| 63 | 63 | throw if we see directories which just look like a worktree dir, but are none. | |
| 64 | 64 | """ | |
| 65 | + d = os.fspath(d) | ||
| 65 | 66 | if osp.isdir(d): | |
| 66 | 67 | if (osp.isdir(osp.join(d, "objects")) or "GIT_OBJECT_DIRECTORY" in os.environ) and osp.isdir( | |
| 67 | 68 | osp.join(d, "refs") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1011,7 +1011,7 @@ class LockFile: | |||
| 1011 | 1011 | __slots__ = ("_file_path", "_owns_lock") | |
| 1012 | 1012 | ||
| 1013 | 1013 | def __init__(self, file_path: PathLike) -> None: | |
| 1014 | - self._file_path = file_path | ||
| 1014 | + self._file_path = os.fspath(file_path) | ||
| 1015 | 1015 | self._owns_lock = False | |
| 1016 | 1016 | ||
| 1017 | 1017 | def __del__(self) -> None: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments