Skip to content

Commit

Permalink
fix pypa#993 and add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Jan 8, 2024
1 parent d5c0e86 commit 9af3ba4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/setuptools_scm/_file_finders/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def git_find_files(path: _t.PathT = "") -> list[str]:
toplevel = _git_toplevel(os.fspath(path))
if not is_toplevel_acceptable(toplevel):
return []
fullpath = os.path.normcase(os.path.abspath(os.path.normpath(path)))
fullpath = norm_real(path)
if not fullpath.startswith(toplevel):
log.warning("toplevel mismatch computed %s vs resolved %s ", toplevel, fullpath)
git_files, git_dirs = _git_ls_files_and_dirs(toplevel)
Expand Down
13 changes: 13 additions & 0 deletions testing/test_file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ def test_case(inwd: WorkDir) -> None:
)


@pytest.mark.skipif(
os.path.normcase("B") != os.path.normcase("b"), reason="case sensitive filesystem"
)
def test_case_cwd_evil(inwd: WorkDir, monkeypatch: pytest.MonkeyPatch) -> None:
(inwd.cwd / "CamelFile").touch()
(inwd.cwd / "file2").touch()
inwd.add_and_commit()
monkeypatch.chdir(inwd.cwd.parent.joinpath(inwd.cwd.name.capitalize()))
assert set(find_files()) == _sep(
{"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"}
)


@pytest.mark.skipif(sys.platform == "win32", reason="symlinks to dir not supported")
def test_symlink_dir(inwd: WorkDir) -> None:
(inwd.cwd / "adir" / "bdirlink").symlink_to("../bdir")
Expand Down

0 comments on commit 9af3ba4

Please sign in to comment.