mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
diff: remove --target
This commit is contained in:
+1
-12
@@ -72,9 +72,7 @@ class CmdDiff(CmdBase):
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
diff = self.repo.diff(
|
||||
self.args.a_ref, self.args.b_ref, target=self.args.target
|
||||
)
|
||||
diff = self.repo.diff(self.args.a_ref, self.args.b_ref)
|
||||
|
||||
if not any(diff.values()):
|
||||
return 0
|
||||
@@ -124,15 +122,6 @@ def add_parser(subparsers, parent_parser):
|
||||
),
|
||||
nargs="?",
|
||||
)
|
||||
diff_parser.add_argument(
|
||||
"-t",
|
||||
"--target",
|
||||
help=(
|
||||
"Source path to a data file or directory. Default None. "
|
||||
"If not specified, compares all files and directories "
|
||||
"that are under DVC control in the current working space."
|
||||
),
|
||||
)
|
||||
diff_parser.add_argument(
|
||||
"--show-json",
|
||||
help="Format the output into a JSON",
|
||||
|
||||
+1
-4
@@ -46,12 +46,10 @@ def _diffables_from_output(output):
|
||||
|
||||
|
||||
@locked
|
||||
def diff(self, a_ref="HEAD", b_ref=None, *, target=None):
|
||||
def diff(self, a_ref="HEAD", b_ref=None):
|
||||
"""
|
||||
By default, it compares the working tree with the last commit's tree.
|
||||
|
||||
When a `target` path is given, it only shows that file's comparison.
|
||||
|
||||
This implementation differs from `git diff` since DVC doesn't have
|
||||
the concept of `index`, but it keeps the same interface, thus,
|
||||
`dvc diff` would be the same as `dvc diff HEAD`.
|
||||
@@ -67,7 +65,6 @@ def diff(self, a_ref="HEAD", b_ref=None, *, target=None):
|
||||
for stage in self.stages
|
||||
for out in stage.outs
|
||||
for diffable in _diffables_from_output(out)
|
||||
if not target or target == str(out)
|
||||
)
|
||||
|
||||
old = outs[a_ref]
|
||||
|
||||
@@ -22,7 +22,7 @@ _dvc_checkout='-d --with-deps -R --recursive -f --force --relink $(compgen -G *.
|
||||
_dvc_commit='-f --force -d --with-deps -R --recursive $(compgen -G *.dvc)'
|
||||
_dvc_config='-u --unset --local --system --global'
|
||||
_dvc_destroy='-f --force'
|
||||
_dvc_diff='-t --target --show-json --checksums'
|
||||
_dvc_diff='-t --show-json --checksums'
|
||||
_dvc_fetch='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -R --recursive $(compgen -G *.dvc)'
|
||||
_dvc_get_url=''
|
||||
_dvc_get='-o --out --rev --show-url'
|
||||
|
||||
@@ -97,7 +97,6 @@ _dvc_destroy=(
|
||||
)
|
||||
|
||||
_dvc_diff=(
|
||||
{-t,--target}"[Source path to a data file or directory.]:Target files:"
|
||||
"--show-json[Format the output into a JSON]"
|
||||
"--checksums[Display checksums for each entry]"
|
||||
{1,2}":Git revision (e.g. branch, tag, SHA):"
|
||||
|
||||
@@ -111,35 +111,6 @@ def test_refs(tmp_dir, scm, dvc):
|
||||
dvc.diff("missing")
|
||||
|
||||
|
||||
def test_target(tmp_dir, scm, dvc):
|
||||
tmp_dir.dvc_gen("foo", "foo")
|
||||
tmp_dir.dvc_gen("bar", "bar")
|
||||
scm.add([".gitignore", "foo.dvc", "bar.dvc"])
|
||||
scm.commit("lowercase")
|
||||
|
||||
tmp_dir.dvc_gen("foo", "FOO")
|
||||
tmp_dir.dvc_gen("bar", "BAR")
|
||||
scm.add(["foo.dvc", "bar.dvc"])
|
||||
scm.commit("uppercase")
|
||||
|
||||
assert dvc.diff("HEAD~1", target="foo") == {
|
||||
"added": [],
|
||||
"deleted": [],
|
||||
"modified": [
|
||||
{
|
||||
"filename": "foo",
|
||||
"checksum": {"old": digest("foo"), "new": digest("FOO")},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
assert dvc.diff("HEAD~1", target="missing") == {
|
||||
"added": [],
|
||||
"deleted": [],
|
||||
"modified": [],
|
||||
}
|
||||
|
||||
|
||||
def test_directories(tmp_dir, scm, dvc):
|
||||
tmp_dir.dvc_gen({"dir": {"1": "1", "2": "2"}}, commit="add a directory")
|
||||
tmp_dir.dvc_gen({"dir": {"3": "3"}}, commit="add a file")
|
||||
|
||||
Reference in New Issue
Block a user