From bf5fe95c30c98bd3026bc7e20ee99beca3b8b054 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Wed, 3 Jan 2024 07:31:47 -0500 Subject: [PATCH] imp_url: gitignore during to_remote op --- dvc/repo/imp_url.py | 1 + tests/func/test_import_url.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dvc/repo/imp_url.py b/dvc/repo/imp_url.py index b243fa8118..1916b437f2 100644 --- a/dvc/repo/imp_url.py +++ b/dvc/repo/imp_url.py @@ -77,6 +77,7 @@ def imp_url( # noqa: PLR0913 elif to_remote: remote_odb = self.cloud.get_remote_odb(remote, "import-url") stage.outs[0].transfer(url, odb=remote_odb, jobs=jobs) + stage.outs[0].ignore() stage.save_deps() stage.md5 = stage.compute_md5() else: diff --git a/tests/func/test_import_url.py b/tests/func/test_import_url.py index e8ae45d721..851296f00d 100644 --- a/tests/func/test_import_url.py +++ b/tests/func/test_import_url.py @@ -10,6 +10,7 @@ from dvc.exceptions import InvalidArgumentError from dvc.stage import Stage from dvc.testing.workspace_tests import TestImport as _TestImport +from tests.utils import get_gitignore_content def test_cmd_import(tmp_dir, dvc): @@ -170,7 +171,7 @@ def test_import_url_preserve_fields(tmp_dir, dvc): ) -def test_import_url_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, local_remote): +def test_import_url_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, scm, local_remote): tmp_abs_dir = make_tmp_dir("abs") tmp_foo = tmp_abs_dir / "foo" tmp_foo.write_text("foo") @@ -181,6 +182,7 @@ def test_import_url_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, local_remote) assert stage.deps[0].fspath == str(tmp_foo) assert stage.outs[0].fspath == os.fspath(foo) assert foo.with_suffix(".dvc").exists() + assert get_gitignore_content() == ["/foo"] def test_import_url_to_remote_invalid_combinations(dvc):