Two new modes --all and --stdin for check-ignore#4323
Conversation
Fix treeverse#4321 Introduce new arguments --all for dvc check-ignore Add tests for dvc check-ignore --all
-all and --stdin for check-ignore--all and --stdin for check-ignore
1. `--stdin` and targets can and only can have one 2. more tests
And I had a problem. I tried to add a pytest to I used monkeypatch to mock user input but was blocked by |
|
@karajan1001 |
Codecov Report
@@ Coverage Diff @@
## master #4323 +/- ##
==========================================
- Coverage 91.24% 91.19% -0.05%
==========================================
Files 177 177
Lines 12182 12209 +27
==========================================
+ Hits 11115 11134 +19
- Misses 1067 1075 +8
Continue to review full report at Codecov.
|
1. Add a new tests with mock stdin for interactive mode 2. Solve the problem of `assert "" in caplog.text` in tests always `True`.
@pared |
When you are using a mocker inside a test, patches and mocks are applied only to this test. So, if you are worried, whether it's possible to "leak" the mock to other tests - no, it should not happen.
I think it's fine to use this patch. |
|
Hi! Maybe you can address #4282 (review) and #4282 (review) here @karajan1001 ? Thanks! |
@jorgeorpinel Let's not do that. Let's not expand the scope of this PR, those changes are completely unrelated. |
I had considered doing so, but give up. BTW, doc of this PR needs to be reviewed as well. |
1. remove path_input and make _ask to a public method instead
|
Thank you @karajan1001 ! 🙏 There are some tiny inconsistencies with stuff like messages, but we'll adjust them along the way. It is great to have such a powerful tool in our toolbox! |
@karajan1001 is there a docs PR for this already? We haven't even merged the previous one 😅 (see treeverse/dvc.org#1629 (comment)) |
|
Not already, I'm waiting for this one. And it would be created soon. |
| "Empty string is not a valid pathspec. Please use . " | ||
| "instead if you meant to match all paths." |
There was a problem hiding this comment.
What is a pathspec?
Can users actually send an empty string (e.g. '')? Or does this happen when you don't send any args?
There was a problem hiding this comment.
pathspecmeans the target to be checked- It is in an interactive mode where users can type string as the target, and this happened when users type send an empty string.
There was a problem hiding this comment.
It is in an interactive mode
So maybe don't say anything and just go to the next > ? Seems intuitive enough that way. I just tried it and noticed it crashes after this error msg (i.e. it stops the interactive mode).
UPDATE: On Windows at least, there's no > chars in interactive mode, see treeverse/dvc.org#1675 (review)
There was a problem hiding this comment.
p.s. when I send an empty string as target i.e. dvc check-ignore '' it just checks it (never matches even if * is a pattern in .dvcignore) and this error isn't presented. Seems slightly inconsistent. I vote to just remove it altogether 🙂
| if self.args.quiet and self.args.details: | ||
| raise DvcException("cannot use both `--details` and `--quiet`") |
There was a problem hiding this comment.
Maybe --quiet should just win here?
There was a problem hiding this comment.
Maybe --quiet should just win here?
Yes, it used to be --verbose and --quiet. They might cause some problems, and had been fixed in #4304.
And for --details and --quiet we can just let --quiet win.
There was a problem hiding this comment.
Left some questions @karajan1001 ☝️
We can discuss my other suggestions in treeverse/dvc.org/pull/1675 and I'll apply them (probably in #4358).
* cmd: remove unnecessary commas in get and import * cmd: fix typo in add * cmd: remote copy edits per #1617 (comment) * guide: .dvcignore copy edit * cmd: init copy edits * clarify about dirs in import -o * cmd: review get -o desc * dvcignore: updates to guide and check-ignore ref. per #1629 (review) et al. * cmd: update check-ignore -n per treeverse/dvc#4323 (comment) * cmd: fix get.import -o descriptions per #1673 (review) and #1673 (review) * cmd: copy edits to remote add/modify
* check_ignore: update help output per #4282 (review) and #4282 (review) * check-ignore: more output string updates per #4323 et al. * check-ignore: min text update to match treeverse/dvc.org/pull/1673 Co-authored-by: Ruslan Kuprieiev <kupruser@gmail.com>
Fix #4321
Introduce new arguments --all for dvc check-ignore
Add tests for dvc check-ignore --all
❗ I have followed the Contributing to DVC checklist.
📖 If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏