Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not overwrite identical files #1576

Merged
merged 5 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
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


sisp marked this conversation as resolved.
Show resolved Hide resolved
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
Loading