Skip to content

Commit 01d8296

Browse files
committed
Repository.hashfile(): Demonstrate workaround for libgit2#6825 on Windows
1 parent 3af4eba commit 01d8296

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/test_repository.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,10 @@ def test_repository_hashfile(testrepo):
908908
assert h == original_hash
909909

910910
# Test absolute path
911-
h = testrepo.hashfile(str(Path(testrepo.workdir, 'hello.txt')))
911+
# For best results on Windows, pass a pure POSIX path. (See https://github.com/libgit2/libgit2/issues/6825)
912+
absolute_path = Path(testrepo.workdir, 'hello.txt')
913+
absolute_path = absolute_path.as_posix() # Windows compatibility
914+
h = testrepo.hashfile(str(absolute_path))
912915
assert h == original_hash
913916

914917
# Test missing path
@@ -944,8 +947,11 @@ def test_repository_hashfile_filter(testrepo):
944947
h = testrepo.hashfile('hellocrlf.txt')
945948
assert h == original_hash
946949

947-
# Treat absolute path with filters
948-
h = testrepo.hashfile(str(Path(testrepo.workdir, 'hellocrlf.txt')))
950+
# Treat absolute path with filters.
951+
# For best results on Windows, pass a pure POSIX path. (See https://github.com/libgit2/libgit2/issues/6825)
952+
absolute_path = Path(testrepo.workdir, 'hellocrlf.txt')
953+
absolute_path = absolute_path.as_posix() # Windows compatibility
954+
h = testrepo.hashfile(str(absolute_path))
949955
assert h == original_hash
950956

951957
# Bypass filters

0 commit comments

Comments
 (0)