Skip to content

Commit

Permalink
GitCopier: handle symlinks correctly. (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Sep 27, 2024
1 parent 877c3af commit d6391de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7-symlink.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "Make ``GitCopier`` handle symlinks correctly (https://github.com/ansible-community/antsibull-fileutils/pull/7)."
2 changes: 1 addition & 1 deletion src/antsibull_fileutils/copier.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def copy(self, from_path: StrPath, to_path: StrPath) -> None:

# Copy the file
dst_path = os.path.join(to_path, file_decoded)
shutil.copyfile(src_path, dst_path)
shutil.copyfile(src_path, dst_path, follow_symlinks=False)


class CollectionCopier:
Expand Down
8 changes: 4 additions & 4 deletions tests/units/test_copier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@


def assert_same(a: pathlib.Path, b: pathlib.Path) -> None:
if a.is_symlink():
assert b.is_symlink()
assert a.readlink() == b.readlink()
return
if a.is_file():
assert b.is_file()
assert a.read_bytes() == b.read_bytes()
return
if a.is_dir():
assert b.is_dir()
return
if a.is_symlink():
assert b.is_symlink()
assert a.readlink() == b.readlink()
return


def test_copier(tmp_path_factory):
Expand Down

0 comments on commit d6391de

Please sign in to comment.