Open jorio opened 4 weeks ago
It looks good, but the tests don't pass on Windows: https://ci.appveyor.com/project/jdavid/pygit2/builds/49936765/job/72q19bou1q95mxy9
Hmm, this looks like a libgit2 issue on Windows.
str(Path(...))
returns a "native" path that uses \
as the directory separator. But git_repository_hashfile
doesn't recognize this path as being part of the workdir – which is required for the test to pass – unless you replace the backslashes with forward slashes.
In other words, editing my test as follows will make it pass on Windows:
# Treat absolute path with filters
absolute_path = str(Path(testrepo.workdir, 'hellocrlf.txt'))
absolute_path = absolute_path.replace('\\', '/') # <--------------- yikes!
h = testrepo.hashfile(absolute_path)
assert h == original_hash
But in this case, I would argue that libgit2 should canonicalize the input path to its preferred form internally.
This exposes libgit2's
git_repository_hashfile()
.pygit2.hashfile()
already exists, but this lets you hash files using the repository's filters.