Skip to content

Commit

Permalink
Repository.hashfile(): Demonstrate workaround for libgit2#6825 on Win…
Browse files Browse the repository at this point in the history
…dows
  • Loading branch information
jorio committed Jul 21, 2024
1 parent 3af4eba commit 01d8296
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,10 @@ def test_repository_hashfile(testrepo):
assert h == original_hash

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

# Test missing path
Expand Down Expand Up @@ -944,8 +947,11 @@ def test_repository_hashfile_filter(testrepo):
h = testrepo.hashfile('hellocrlf.txt')
assert h == original_hash

# Treat absolute path with filters
h = testrepo.hashfile(str(Path(testrepo.workdir, 'hellocrlf.txt')))
# Treat absolute path with filters.
# For best results on Windows, pass a pure POSIX path. (See https://github.com/libgit2/libgit2/issues/6825)
absolute_path = Path(testrepo.workdir, 'hellocrlf.txt')
absolute_path = absolute_path.as_posix() # Windows compatibility
h = testrepo.hashfile(str(absolute_path))
assert h == original_hash

# Bypass filters
Expand Down

0 comments on commit 01d8296

Please sign in to comment.