Repository navigation
[package-deps-hash] Skip untracked nested Git repositories when computing repo state - #6239
Open
Ian Clanton-Thuon (iclanton) wants to merge 3 commits into
Open
Ian Clanton-Thuon (iclanton) wants to merge 3 commits into
Ian Clanton-Thuon (iclanton) wants to merge 3 commits into
Conversation
…ting repo state A submodule removed by a checkout can be left on disk when its folder is not empty. `git status -u` doesn't descend into untracked nested Git repositories and reports them as folders with a trailing slash, which `git hash-object` fails to hash, aborting the repo-state calculation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…n computing repo state
This branch has not been deployed
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
When a checkout removes a submodule but its folder isn't empty, Git warns
unable to rmdir '<path>': Directory not emptyand leaves the folder on disk as an untracked nested Git repository. Rush then fails to compute the repo state with:and, with the build cache enabled, fails with
Build cache is only supported if running in a Git repository.This was hit in CI on a persistent agent right after merging a PR that removed a submodule. It isn't specific to shallow clones; it reproduces with full history.
Details
git status -ulists every file in untracked folders, but it doesn't look inside an untracked nested Git repository (a folder with a.gitin it). It reports that folder once, with a trailing/.classifyLocallyModifiedFilespassed that path togit hash-object, which can't hash a folder, so the whole calculation failed.The fix skips
workingTreeentries that end in/. They are neither hashed nor removed, andhasUncommittedChangesis stilltrue. Ordinary untracked files in untracked folders are unaffected, because-ulists them individually.RepoStateCacheuses the same classifier, and it runsgit statuswithstatus.showUntrackedFiles=all, so it gets the same fix.The contents of an untracked nested repository were never included in the state before (Git doesn't list them), so this doesn't change any hashes; it only stops the failure.
How it was tested
Added two tests in
UnhashablePaths.test.ts, which check bothgetDetailedRepoStateAsyncandRepoStateCache:Both tests failed with
Unable to hash ...before the fix. ThegetRepoState,UnhashablePathsandRepoStateCachesuites pass (96 tests), along with the build, lint and API Extractor.