dvc: more explict error during init when .dvc is ignored by git#4978
Conversation
| return entry, gitignore | ||
|
|
||
| def _ignored(self, path): | ||
| def is_ignored(self, path): |
There was a problem hiding this comment.
I renamed it because it's used as a public method in the PR.
| *.pyc | ||
| .env/ | ||
| .env2.7/ | ||
| .python-version |
There was a problem hiding this comment.
This is a pyenv file, right? I'm not a pyenv user (and we recommend using virtualenvs for anyone doing development on DVC), is it normal to gitignore this?
There was a problem hiding this comment.
Yes, .python-version is used by pyenv. It's typical to ignore it in projects intended to be ran in multiple environments:
https://github.com/github/gitignore/blob/master/Python.gitignore#L88
Note that pyenv with pyenv-virtualenv plugin is just a convenience wrapper on top of virtualenv. This is a very common way to use it, so virtualenv is still being used. .python-version is a convenient feature that switches local shell env to what's mentioned in that file. It's typically a single line of text there.
| with caplog.at_level(logging.ERROR, logger="dvc"): | ||
| assert main(["init"]) == 1 |
There was a problem hiding this comment.
It may be better to test Repo.init() here rather than using main (since this is an issue with the init internals, not necessarily with only the command line dvc init).
So something like
with pytest.raises(InitError):
# test using DvcRepo.init() instead of main()
...There was a problem hiding this comment.
It may be better to leave testing with main and checking caplog in this functional test. If only an exception is checked when DvcRepo.init() is called it may not test the full scenario that happened to users.
In issues
the users did not see a clear message about the issue. Even though the exception when calling the init method has that message, it could happen in the future that it gets suppressed somehow and is not displayed to users. Testing it with main would make it more robust.
| f"{dvc_dir} is ignored by your SCM tool. \n" | ||
| "Make sure that it's tracked, " | ||
| "for example, by adding '!.dvc' to .gitignore." |
There was a problem hiding this comment.
Thanks fot this update!
BTW what do you guys think about just saying "Git" for 2.x +?
I don't know of any plans to support other SCMs soon anyway... Docs already only ever mention Git.
Fixes #3738
❗ 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.