Fix: dvc status works with ** globbing patterns in .gitignore#11002
Closed
paipeline wants to merge 3 commits intotreeverse:mainfrom
Closed
Fix: dvc status works with ** globbing patterns in .gitignore#11002paipeline wants to merge 3 commits intotreeverse:mainfrom
paipeline wants to merge 3 commits intotreeverse:mainfrom
Conversation
Fixes issue treeverse#10987: dvc status reports 'no data tracked' when using ** globbing patterns in .gitignore with negations. Root cause: collect_files() was using Git's scm.is_ignored() for all files including .dvc files. Git's ignore system has different behavior for complex ** patterns with negations compared to DVC's ignore system. Solution: Use DVC's own dvcignore.is_ignored_file() for .dvc files, which properly handles ** globbing patterns with negations like: - data/raw/** (ignore everything) - !data/raw/**/*.dvc (except .dvc files) This ensures .dvc files are correctly recognized even when they're in directories that are ignored by ** patterns. Changes: - Modified is_ignored() in dvc/repo/index.py to use DVC's ignore system for .dvc files and Git's system for other files - Added comprehensive test coverage for various ** globbing scenarios - Maintains backward compatibility for all existing ignore behavior
for more information, see https://pre-commit.ci
|
paipeline seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Author
|
Auto-closed, finding correct repo |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issue #10987:
dvc statusreports "no data tracked" when using ** globbing patterns in .gitignore with negations.Problem
When using complex .gitignore patterns like:
data/raw/**!data/raw/**/*.dvcDVC's collect_files() function incorrectly determined that .dvc files were ignored, causing dvc status to report "There are no data or pipelines tracked in this project yet." even though .dvc files existed and were committed to git.
Root Cause
The collect_files() function was using Git's scm.is_ignored() for all files, including .dvc files. Git's ignore system has different behavior for complex ** patterns with negations compared to DVC's ignore system.
Solution
Modified is_ignored() function in dvc/repo/index.py to:
This ensures .dvc files are correctly recognized even when they're in directories ignored by ** patterns.
Changes
Testing
Impact
Closes #10987