| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -617,11 +617,11 @@ def _preprocess_add_items( | |||
| 617 | 617 | paths = [] | |
| 618 | 618 | entries = [] | |
| 619 | 619 | # if it is a string put in list | |
| 620 | - if isinstance(items, str): | ||
| 620 | + if isinstance(items, (str, os.PathLike)): | ||
| 621 | 621 | items = [items] | |
| 622 | 622 | ||
| 623 | 623 | for item in items: | |
| 624 | - if isinstance(item, str): | ||
| 624 | + if isinstance(item, (str, os.PathLike)): | ||
| 625 | 625 | paths.append(self._to_relative_path(item)) | |
| 626 | 626 | elif isinstance(item, (Blob, Submodule)): | |
| 627 | 627 | entries.append(BaseIndexEntry.from_blob(item)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,8 @@ | |||
| 37 | 37 | import os.path as osp | |
| 38 | 38 | from git.cmd import Git | |
| 39 | 39 | ||
| 40 | + from pathlib import Path | ||
| 41 | + | ||
| 40 | 42 | HOOKS_SHEBANG = "#!/usr/bin/env sh\n" | |
| 41 | 43 | ||
| 42 | 44 | is_win_without_bash = is_win and not shutil.which("bash.exe") | |
@@ -943,3 +945,12 @@ def test_commit_msg_hook_fail(self, rw_repo): | |||
| 943 | 945 | assert str(err) | |
| 944 | 946 | else: | |
| 945 | 947 | raise AssertionError("Should have caught a HookExecutionError") | |
| 948 | + | ||
| 949 | + @with_rw_repo('HEAD') | ||
| 950 | + def test_index_add_pathlike(self, rw_repo): | ||
| 951 | + git_dir = Path(rw_repo.git_dir) | ||
| 952 | + | ||
| 953 | + file = git_dir / "file.txt" | ||
| 954 | + file.touch() | ||
| 955 | + | ||
| 956 | + rw_repo.index.add(file) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments