Skip to content

Commit bf5fe95

Browse files
dberenbaumefiop
authored andcommitted
imp_url: gitignore during to_remote op
1 parent fe008d9 commit bf5fe95

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

dvc/repo/imp_url.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def imp_url( # noqa: PLR0913
7777
elif to_remote:
7878
remote_odb = self.cloud.get_remote_odb(remote, "import-url")
7979
stage.outs[0].transfer(url, odb=remote_odb, jobs=jobs)
80+
stage.outs[0].ignore()
8081
stage.save_deps()
8182
stage.md5 = stage.compute_md5()
8283
else:

tests/func/test_import_url.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from dvc.exceptions import InvalidArgumentError
1111
from dvc.stage import Stage
1212
from dvc.testing.workspace_tests import TestImport as _TestImport
13+
from tests.utils import get_gitignore_content
1314

1415

1516
def test_cmd_import(tmp_dir, dvc):
@@ -170,7 +171,7 @@ def test_import_url_preserve_fields(tmp_dir, dvc):
170171
)
171172

172173

173-
def test_import_url_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, local_remote):
174+
def test_import_url_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, scm, local_remote):
174175
tmp_abs_dir = make_tmp_dir("abs")
175176
tmp_foo = tmp_abs_dir / "foo"
176177
tmp_foo.write_text("foo")
@@ -181,6 +182,7 @@ def test_import_url_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, local_remote)
181182
assert stage.deps[0].fspath == str(tmp_foo)
182183
assert stage.outs[0].fspath == os.fspath(foo)
183184
assert foo.with_suffix(".dvc").exists()
185+
assert get_gitignore_content() == ["/foo"]
184186

185187

186188
def test_import_url_to_remote_invalid_combinations(dvc):

0 commit comments

Comments
 (0)