| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e3e5da8 commit b10e250
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,7 @@ | |||
| 40 | 40 | from git.util import Actor, cwd, hex_to_bin, rmtree | |
| 41 | 41 | ||
| 42 | 42 | from test.lib import TestBase, VirtualEnvironment, fixture, fixture_path, with_rw_directory, with_rw_repo, PathLikeMock | |
| 43 | - from test.lib.helper import xfail_if_raises | ||
| 43 | + from test.lib.helper import symlinks_supported, xfail_if_raises | ||
| 44 | 44 | ||
| 45 | 45 | HOOKS_SHEBANG = "#!/usr/bin/env sh\n" | |
| 46 | 46 | ||
@@ -175,19 +175,6 @@ def _decode(stdout): | |||
| 175 | 175 | _win_bash_status = WinBashStatus.check() | |
| 176 | 176 | ||
| 177 | 177 | ||
| 178 | - def _windows_supports_symlinks(): | ||
| 179 | - if sys.platform != "win32": | ||
| 180 | - return False | ||
| 181 | - | ||
| 182 | - with tempfile.TemporaryDirectory(prefix="gitpython-symlink-check-") as temp_dir: | ||
| 183 | - link_path = osp.join(temp_dir, "link") | ||
| 184 | - try: | ||
| 185 | - os.symlink("missing-target", link_path) | ||
| 186 | - except (NotImplementedError, OSError): | ||
| 187 | - return False | ||
| 188 | - return S_ISLNK(os.lstat(link_path)[ST_MODE]) | ||
| 189 | - | ||
| 190 | - | ||
| 191 | 178 | def _make_hook(git_dir, name, content, make_exec=True): | |
| 192 | 179 | """A helper to create a hook""" | |
| 193 | 180 | hp = hook_path(name, git_dir) | |
@@ -655,7 +642,7 @@ def _count_existing(self, repo, files): | |||
| 655 | 642 | @with_rw_repo("0.1.6") | |
| 656 | 643 | def test_index_mutation(self, rw_repo): | |
| 657 | 644 | with xfail_if_raises( | |
| 658 | - sys.platform == "win32" and (Git().config("core.symlinks") == "true" or _windows_supports_symlinks()), | ||
| 645 | + sys.platform == "win32" and (Git().config("core.symlinks") == "true" or symlinks_supported()), | ||
| 659 | 646 | raises=(FileNotFoundError, GitCommandError), | |
| 660 | 647 | reason="Assumes symlinks are not created on Windows and opens a symlink to a nonexistent target.", | |
| 661 | 648 | ): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ | |||
| 28 | 28 | import git.refs as refs | |
| 29 | 29 | from git.util import Actor | |
| 30 | 30 | ||
| 31 | - from test.lib import TestBase, with_rw_repo, PathLikeMock | ||
| 31 | + from test.lib import TestBase, requires_symlinks, with_rw_repo, PathLikeMock | ||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | class TestRefs(TestBase): | |
@@ -780,6 +780,7 @@ def test_symbolic_reference_log_append_rejects_path_traversal(self): | |||
| 780 | 780 | ) | |
| 781 | 781 | assert not outside_path.exists() | |
| 782 | 782 | ||
| 783 | + @requires_symlinks | ||
| 783 | 784 | def test_symbolic_reference_set_reference_rejects_symlink_escape(self): | |
| 784 | 785 | with tempfile.TemporaryDirectory() as tmp_dir: | |
| 785 | 786 | base_dir = Path(tmp_dir) | |
@@ -791,10 +792,7 @@ def test_symbolic_reference_set_reference_rejects_symlink_escape(self): | |||
| 791 | 792 | refs_heads_dir = Path(repo.common_dir) / "refs" / "heads" | |
| 792 | 793 | refs_heads_dir.mkdir(parents=True, exist_ok=True) | |
| 793 | 794 | symlink_path = refs_heads_dir / "link_out" | |
| 794 | - try: | ||
| 795 | - symlink_path.symlink_to(outside_dir, target_is_directory=True) | ||
| 796 | - except (OSError, NotImplementedError) as ex: | ||
| 797 | - self.skipTest("symlinks unavailable on this platform: %s" % ex) | ||
| 795 | + symlink_path.symlink_to(outside_dir, target_is_directory=True) | ||
| 798 | 796 | if osp.realpath(symlink_path / "escaped") == osp.abspath(symlink_path / "escaped"): | |
| 799 | 797 | self.skipTest("realpath does not resolve directory symlinks on this platform") | |
| 800 | 798 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments