fix(config): read config from workspace, not git history#10965
Open
GreenHatHG wants to merge 8 commits intotreeverse:mainfrom
Open
fix(config): read config from workspace, not git history#10965GreenHatHG wants to merge 8 commits intotreeverse:mainfrom
GreenHatHG wants to merge 8 commits intotreeverse:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10965 +/- ##
==========================================
+ Coverage 90.68% 91.00% +0.32%
==========================================
Files 504 506 +2
Lines 39795 41161 +1366
Branches 3141 3264 +123
==========================================
+ Hits 36087 37460 +1373
- Misses 3042 3063 +21
+ Partials 666 638 -28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…read from workspace or git history.
Contributor
Author
|
Hi maintainers, I noticed several unit tests are failing, but they all appear to be unrelated to my changes: |
Contributor
Author
|
Hi maintainers, |
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 #10560
Root Cause
When
dvc gc --all-commitstraverses commit history, it switches the filesystem toGitFileSystemto read files from git. The Config class then reads configuration files using different filesystems for different levels:.dvc/config(repo level): Read fromGitFileSystem→ gets config from git history.dvc/config.local(local level): Read fromLocalFileSystem→ gets config from workspaceThis mixed reading causes incomplete configuration:
.dvc/config(e.g., remote was added later or in early commits).dvc/config.localThe core issue:
dvc gc --all-commits --cloudneeds the current workspace remote configuration to access cloud storage, but Config class was reading.dvc/configfrom git history instead of workspace, leading to incomplete or outdated configuration.Solution
Fixed the mixed reading issue by introducing scenario-aware config loading in Config class:
Added
_should_prefer_local_dvc_dirproperty to detect the scenario:Returns True for brancher scenario (
dvc gc --all-commits): when dvc_dir is a git root path and workspace has config file.Returns False for
Repo(rev="...")scenario: when explicitly accessing a specific revisionUpdated files property to use consistent source:
Repo(rev="...")scenario: uses dvc_dir + fs for repo config path → reads from git historyUpdated
_get_fs()method to return appropriate filesystem:Repo(rev="...")scenario: returns fs for repo level → preserves git history readingThis ensures both
.dvc/configand.dvc/config.localare read from the same source, eliminating the mixed reading issue.Reproduce Bash
error: