mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 23:10:24 +01:00
import: add '--file' option (#4622)
* import: add '--file' option Fixes #4093 * Update dvc/command/imp.py Co-authored-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
co-authored by
Ruslan Kuprieiev
parent
a5ab01390f
commit
738dfd49cf
@@ -15,6 +15,7 @@ class CmdImport(CmdBase):
|
||||
self.args.url,
|
||||
self.args.path,
|
||||
out=self.args.out,
|
||||
fname=self.args.file,
|
||||
rev=self.args.rev,
|
||||
)
|
||||
except DvcException:
|
||||
@@ -59,4 +60,9 @@ def add_parser(subparsers, parent_parser):
|
||||
help="Git revision (e.g. SHA, branch, tag)",
|
||||
metavar="<commit>",
|
||||
)
|
||||
import_parser.add_argument(
|
||||
"--file",
|
||||
help="Specify name of the DVC-file this command will generate.",
|
||||
metavar="<filename>",
|
||||
)
|
||||
import_parser.set_defaults(func=CmdImport)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
def imp(self, url, path, out=None, rev=None):
|
||||
def imp(self, url, path, out=None, fname=None, rev=None):
|
||||
erepo = {"url": url}
|
||||
if rev is not None:
|
||||
erepo["rev"] = rev
|
||||
|
||||
return self.imp_url(path, out=out, erepo=erepo, frozen=True)
|
||||
return self.imp_url(path, out=out, fname=fname, erepo=erepo, frozen=True)
|
||||
|
||||
@@ -4,7 +4,17 @@ from dvc.command.imp import CmdImport
|
||||
|
||||
def test_import(mocker):
|
||||
cli_args = parse_args(
|
||||
["import", "repo_url", "src", "--out", "out", "--rev", "version"]
|
||||
[
|
||||
"import",
|
||||
"repo_url",
|
||||
"src",
|
||||
"--out",
|
||||
"out",
|
||||
"--file",
|
||||
"file",
|
||||
"--rev",
|
||||
"version",
|
||||
]
|
||||
)
|
||||
assert cli_args.func == CmdImport
|
||||
|
||||
@@ -13,4 +23,6 @@ def test_import(mocker):
|
||||
|
||||
assert cmd.run() == 0
|
||||
|
||||
m.assert_called_once_with("repo_url", path="src", out="out", rev="version")
|
||||
m.assert_called_once_with(
|
||||
"repo_url", path="src", out="out", fname="file", rev="version"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user