dvcfile: preserve 'remote' on add and commit

Preserves 'remote' output on dvc add and dvc commit.

Fixes #7356
This commit is contained in:
Samuel Knight
2022-05-05 08:36:37 +05:45
committed by skshetry
parent c64db917f5
commit 1f5f2f5c97
6 changed files with 51 additions and 9 deletions
+31
View File
@@ -1,4 +1,5 @@
import os
import textwrap
import pytest
@@ -39,6 +40,36 @@ def test_commit_force(tmp_dir, dvc):
assert dvc.status([stage.path]) == {}
def test_commit_preserve_fields(tmp_dir, dvc):
text = textwrap.dedent(
"""\
# top comment
desc: top desc
outs:
- path: foo # out comment
desc: out desc
remote: testremote
meta: some metadata
"""
)
tmp_dir.gen("foo.dvc", text)
tmp_dir.dvc_gen("foo", "foo", commit=False)
dvc.commit("foo")
assert (tmp_dir / "foo.dvc").read_text() == textwrap.dedent(
"""\
# top comment
desc: top desc
outs:
- path: foo # out comment
desc: out desc
remote: testremote
md5: acbd18db4cc2f85cedef654fccc4a4d8
size: 3
meta: some metadata
"""
)
@pytest.mark.parametrize("run_kw", [{"single_stage": True}, {"name": "copy"}])
def test_commit_with_deps(tmp_dir, dvc, run_copy, run_kw):
tmp_dir.gen("foo", "foo")