From a378e017e1e3f53ea160786d1ca98a858b7f7a27 Mon Sep 17 00:00:00 2001 From: Zhenyu Gao Date: Tue, 8 Feb 2022 03:56:48 -0800 Subject: [PATCH] Fix dvc add -o issue #7357 --- dvc/stage/__init__.py | 1 + tests/func/test_add.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/dvc/stage/__init__.py b/dvc/stage/__init__.py index c4a1e4430..34eab5206 100644 --- a/dvc/stage/__init__.py +++ b/dvc/stage/__init__.py @@ -404,6 +404,7 @@ class Stage(params.StageParams): out.transfer(source, odb=odb, jobs=kwargs.get("jobs")) if not to_remote: out.checkout() + out.ignore() @rwlocked(read=["deps"], write=["outs"]) def reproduce(self, interactive=False, **kwargs): diff --git a/tests/func/test_add.py b/tests/func/test_add.py index 43c2f3c00..9bc660dd9 100644 --- a/tests/func/test_add.py +++ b/tests/func/test_add.py @@ -1033,6 +1033,13 @@ def test_add_to_cache_file(tmp_dir, dvc, local_cloud): assert foo.read_text() == "foo" +def test_add_with_out(tmp_dir, scm, dvc): + tmp_dir.gen({"foo": "foo"}) + dvc.add("foo", out="out_foo") + gitignore_content = get_gitignore_content() + assert "/out_foo" in gitignore_content + + def test_add_to_cache_different_name(tmp_dir, dvc, local_cloud): local_cloud.gen({"data": {"foo": "foo", "bar": "bar"}})