worktree: don't modify index entries in place (#10024)

This commit is contained in:
Ruslan Kuprieiev
2023-10-17 16:30:19 +03:00
committed by GitHub
parent 5f8afb911e
commit 46c65fdba2
7 changed files with 96 additions and 51 deletions
+1 -26
View File
@@ -1,24 +1,6 @@
import pytest
COPY_SCRIPT = """
import os
import shutil
import sys
if os.path.isfile(sys.argv[1]):
shutil.copyfile(sys.argv[1], sys.argv[2])
else:
shutil.copytree(sys.argv[1], sys.argv[2])
""".replace(
"\r\n", "\n"
)
def _add_script(tmp_dir, path, contents=""):
script, *_ = tmp_dir.gen(path, contents.encode("utf-8"))
if hasattr(tmp_dir, "scm"):
tmp_dir.scm_add(path, commit=f"add {path}")
return script.fs_path
from dvc.testing.scripts import _add_script
@pytest.fixture
@@ -38,13 +20,6 @@ with Path(sys.argv[1]).open("a+", encoding="utf-8") as f:
)
@pytest.fixture
def copy_script(
tmp_dir,
):
return _add_script(tmp_dir, "copy.py", COPY_SCRIPT)
@pytest.fixture
def head_script(tmp_dir):
"""Output first line of each file to different file with '-1' appended.