Skip to content

Commit

Permalink
fix: do not overwrite identical files (copier-org#1576)
Browse files Browse the repository at this point in the history
  • Loading branch information
kefirbandi committed Apr 21, 2024
1 parent 19263d5 commit 10fbbcc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion copier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _render_allowed(
quiet=self.quiet,
file_=sys.stderr,
)
return True
return is_dir
return self._solve_render_conflict(dst_relpath)

def _ask(self) -> None: # noqa: C901
Expand Down
12 changes: 12 additions & 0 deletions tests/test_copy.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from __future__ import annotations

import filecmp
import os
import platform
import stat
import sys
from contextlib import nullcontext as does_not_raise
from decimal import Decimal
from enum import Enum
from pathlib import Path
from time import sleep
from typing import Any, ContextManager

import pytest
Expand Down Expand Up @@ -297,6 +299,16 @@ def test_skip_if_exists(tmp_path: Path) -> None:
assert (tmp_path / "meh" / "c.noeof.txt").read_text() == "SKIPPED"


def test_timestamp_identical(tmp_path: Path) -> None:
copier.run_copy(str(Path("tests", "demo_skip_dst")), tmp_path)
modification_time_before = os.path.getmtime(tmp_path / "a.noeof.txt")
sleep(2)
copier.run_copy(str(Path("tests", "demo_skip_dst")), tmp_path)
modification_time_after = os.path.getmtime(tmp_path / "a.noeof.txt")

assert modification_time_before == modification_time_after


def test_skip_if_exists_rendered_patterns(tmp_path: Path) -> None:
copier.run_copy("tests/demo_skip_dst", tmp_path)
copier.run_copy(
Expand Down

0 comments on commit 10fbbcc

Please sign in to comment.