Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BF: drop: Adjust annex's "use --force" message to avoid confusion
Calling `datalad drop` on a file that has too few copies will confusingly propagate a message from `git annex drop` suggesting to use --force, an option `datalad drop` does not have. Replace --force with --nocheck. The new message may still be confusing to Python callers of drop() because it suggests --nocheck rather than check=False, but that's not a problem unique to this spot and is preferable to reporting the completely wrong option. Fixes #5135.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# ex: set sts=4 ts=4 sw=4 noet: | ||
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## | ||
# | ||
# See COPYING file distributed along with the datalad package for the | ||
# copyright and license terms. | ||
# | ||
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## | ||
"""Test drop command | ||
""" | ||
|
||
from datalad.distribution.dataset import Dataset | ||
from datalad.support.exceptions import IncompleteResultsError | ||
from datalad.tests.utils import ( | ||
assert_status, | ||
assert_in, | ||
assert_raises, | ||
with_tree, | ||
) | ||
|
||
|
||
@with_tree({"foo": "foo"}) | ||
def test_drop_file_need_nocheck(path): | ||
ds = Dataset(path).create(force=True) | ||
ds.save() | ||
with assert_raises(IncompleteResultsError) as cme: | ||
ds.drop("foo") | ||
# The --force suggestion from git-annex-drop is translated to --nocheck. | ||
assert_in("--nocheck", str(cme.exception)) | ||
assert_status("ok", ds.drop("foo", check=False, on_failure="ignore")) |