| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b8c000e commit 83c3e64
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,9 +87,12 @@ def is_git_dir(d: PathLike) -> bool: | |||
| 87 | 87 | if common_dir == "": | |
| 88 | 88 | return False | |
| 89 | 89 | if common_dir is None: | |
| 90 | + common_dir_file = Path(d) / "commondir" | ||
| 90 | 91 | try: | |
| 91 | - common_dir = os.fsdecode((Path(d) / "commondir").read_bytes()).rstrip("\r\n") | ||
| 92 | + common_dir = os.fsdecode(common_dir_file.read_bytes()).rstrip("\r\n") | ||
| 92 | 93 | except FileNotFoundError: | |
| 94 | + if osp.lexists(common_dir_file): | ||
| 95 | + return False | ||
| 93 | 96 | common_dir = os.fspath(d) | |
| 94 | 97 | except OSError: | |
| 95 | 98 | return False | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,6 +181,17 @@ def test_repo_discovery_rejects_invalid_metadata(self): | |||
| 181 | 181 | with self.subTest(metadata=".git", contents=contents): | |
| 182 | 182 | self.assertRaises(InvalidGitRepositoryError, Repo, path) | |
| 183 | 183 | ||
| 184 | + @requires_symlinks | ||
| 185 | + def test_repo_discovery_rejects_dangling_commondir(self): | ||
| 186 | + with tempfile.TemporaryDirectory() as tdir: | ||
| 187 | + path = Path(tdir) | ||
| 188 | + (path / "objects").mkdir() | ||
| 189 | + (path / "refs").mkdir() | ||
| 190 | + (path / "HEAD").write_text("ref: refs/heads/main\n") | ||
| 191 | + (path / "commondir").symlink_to("missing") | ||
| 192 | + | ||
| 193 | + self.assertRaises(InvalidGitRepositoryError, Repo, path) | ||
| 194 | + | ||
| 184 | 195 | def test_repo_discovery_uses_storage_environment(self): | |
| 185 | 196 | with tempfile.TemporaryDirectory() as tdir: | |
| 186 | 197 | git_dir = Path(tdir) / "git" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments