Repository navigation
test(guards): resolve the repo root without git rev-parse under the pre-commit hook - #1343
Merged
Merged
Conversation
…re-commit hook TenancyDocsFreshnessTests.RepoRoot() now uses GuardScanner.FindRepoRoot. Under the pre-commit hook in a linked worktree, git exports GIT_DIR without GIT_WORK_TREE, so rev-parse returned the test's bin folder and FileSizeLimitTests and SpellingScannerRatchetTests failed. Refs #1342
…iles With a wrong repo root, every tracked path fails File.Exists and is skipped, so the guard passed while reading nothing. It now requires more than 1,000 files read (2,561 measured on 2026-10-21). Refs #1342
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.
Closes #1342
Why
In a linked worktree, the pre-commit hook exports
GIT_DIRwithoutGIT_WORK_TREE.TenancyDocsFreshnessTests.RepoRoot()rangit rev-parse --show-toplevelfrom the test'sbinfolder, so git returned thatbinfolder.FileSizeLimitTestsandSpellingScannerRatchetTeststhen threwDirectoryNotFoundException, and commits in worktrees fell back to--no-verify.The issue says all three tests failed.
TenancyDocsFreshnessTestspassed. It skips paths that are missing on disk, so it read 0 files and found nothing to flag.What changed
One test file,
tests/Cluckwork.Application.Tests/Documentation/TenancyDocsFreshnessTests.cs:RepoRoot()usesGuardScanner.FindRepoRoot, the same asRenameAccountDocsTests.RepoRoot().TenancyDocsFreshnessRepoRootTestssetsGIT_DIRto the checkout's real git dir and asserts that the returned root holdsCluckwork.slnx. The existingRenameAccountDocsRepoRootTestscovers only the other helper.Verification
dotnet build Cluckwork.slnxreports 0 warnings. The filtered tests (TenancyDocsFreshness,FileSizeLimitTests,SpellingScannerRatchetTests,RenameAccountDocsRepoRootTests) pass 7/7, both normally and withGIT_DIRset to the worktree's git dir.GIT_DIRexported to the worktree's git dir,FileSizeLimitTestsandSpellingScannerRatchetTeststhrowDirectoryNotFoundExceptionunderbin/Debug/net10.0/, and the tenancy walk fails withRead only 0 tracked files under .../bin/Debug/net10.0. Before the floor, the tenancy walk passed in this setup.GIT_DIRexported, the new test setsGIT_DIRitself and fails withRepoRoot() returned .../bin/Debug/net10.0.git ls-filesoutput. It stayed green against the old helper, becausels-fileslists the whole index even when git takesbinas the work tree. The test now checks the file on disk instead.--no-verify(Domain 496/496, Application 783/783).