Conversation
…ot is set When --strip-root is used, Provenant now excludes the root directory entry from the files array, matching ScanCode's skip_root=True behavior. Previously, the root entry was kept with its path shortened to just the basename, which caused duplicate path entries when a child directory shared the root's name (e.g. project/project/inner.txt). Single-resource scans (one file or one empty directory) preserve the root entry, consistent with ScanCode's has_single_resource exception. Signed-off-by: Adrian Braemer <bradrian@gmail.com>
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
--strip-rootnow excludes the root directory entry from thefilesoutput array, matching ScanCode'sskip_root=Truebehaviormyproject/myproject/inner.txtproduced two entries with pathmyproject)has_single_resourceexceptionDetails
Previously,
normalize_pathswith--strip-rootwould keep the root directory entry in the output but rename its path to just the basename (e.g.,/tmp/myproject→myproject). ScanCode instead usesskip_root=TrueinCodebase.walk()to exclude the root entry entirely. This divergence caused duplicate path entries in the collision case and was a general parity bug.The fix adds a dedicated step at the start of
normalize_pathsthat removes the root directory entry whenstrip_root=trueand the scan has more than one resource. The path normalization loop continues unchanged after removal.The
normalize_paths_for_testsignature was updated from&mut [FileInfo]to&mut Vec<FileInfo>, and a workaround in golden test utilities that re-added the root entry after normalization was removed (no longer needed).Test coverage
normalize_paths_strip_root_removes_root_directory_entry— root dir removed, children keptnormalize_paths_strip_root_keeps_root_entry_for_single_file_scan— single-resource file exceptionnormalize_paths_strip_root_keeps_root_entry_for_single_directory_scan— single-resource empty-dir exceptionnormalize_paths_strip_root_removes_root_but_keeps_same_named_child— collision case no longer produces duplicatesnormalize_paths_without_strip_root_keeps_root_directory_entry— default behavior unchanged