-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dvcignore: api to unhide subrepos directory #4324
Conversation
@@ -222,7 +240,8 @@ def _update(self, dirname): | |||
def _update_sub_repo(self, root, dirs): | |||
for d in dirs: | |||
if self._is_dvc_repo(root, d): | |||
new_pattern = DvcIgnorePatterns(["/{}/".format(d)], root) | |||
self._ignored_subrepos.add(f"{root}{os.sep}{d}") | |||
new_pattern = DvcIgnorePatterns([f"/{d}/"], root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that fstrings are better than format() , but there wasn't really a reason to change it in this PR π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change that before when I was experimenting with it. And, f-string is easy to read and understand (here, speed does not matter but could have been another reason), and therefore, I kept it.
I implemented this inside dvcignore, and it should not require "internal" APIs hack as we discussed before. Right now, `ignore_subrepos` will only work for the paths of subrepo, not anything inside it. And the API user is more or less only RepoTree, so should be safe (we switch DvcTree and repo.tree based on path prefixes, so this is only required during `walk`, so as it shows the repo that were previously dvcignored and so that we could switch the trees later during walk. So, if dir is `dir -> repo` So, `tree.walk("dir")` will return `[]`, whereas `tree.walk("dir", ignore_subrepos=False)` will return `["repo"]` But, successive walk will just return `("repo", [], [])`, and could just be ignored as a side-effect.
4e013e1
to
bc01116
Compare
β 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. π
Part of #3369
I implemented this inside dvcignore, and it
should not require "internal" APIs hack as we discussed before.
Right now,
ignore_subrepos
will only work for the paths of subrepo,not anything inside it. And the API user is more or less only
RepoTree, so should be safe (we switch DvcTree and repo.tree based
on path prefixes, so this is only required during
walk
, so as itshows the repo that were previously dvcignored and so that we could
switch the trees later during walk.
So, if dir is
dir -> repo
So,
tree.walk("dir")
will return[]
,whereas
tree.walk("dir", ignore_subrepos=False)
will return["repo"]
But, successive walk will just return
("repo", [], [])
, and couldjust be ignored as a side-effect.