Repository navigation
[#138] Do not truncate the output database when no input files match - #161
Merged
SkowronskiAndrew merged 1 commit intoNov 19, 2026
Conversation
…input files match When the input paths match no files, analyze opened the output database (truncating any existing one) before finding there was nothing to do. Check for an empty input set before the database is created.
SkowronskiAndrew
approved these changes
Nov 19, 2026
SkowronskiAndrew
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for your contribution, I've reviewed and confirms this covers #138.
There is one other case, if there are files found but they are all ignored. But that is outside the scope of this bug, i will land this.
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.
When the input paths match no files,
analyzecreated the output database before finding out there was nothing to do.SQLiteWriter.Begintruncates the file, so a previous analysis at the-opath was lost.This adds the
files.Count == 0check suggested in the issue. It runs afterPrepareContentDirectoryInputs, because that step can add build history files to the input. The check runs before the database is opened, so it now printsError: the input paths matched no files to analyze., returns 1, and leaves the file alone.On the points the issue leaves open:
--search-patternrather than at the files.A mistyped path is already rejected by the
ExistingOnly()validation on thepathsargument, so the test covers the case that still gets through: an existing directory that contains no files (a--search-patternthat matches nothing takes the same path).Analyze_NoInputFiles_KeepsDatabaseOfPreviousRunbuilds a database, runs analyze on an empty folder with the same-o, and checks the exit code, the message, and that the database bytes are unchanged. It fails without the change.dotnet test -c Release: Analyzer.Tests 67 passed, UnityFileSystem.Tests 442 passed (10 skipped), UnityDataTool.Tests 358 passed. Tested on Windows only.Closes #138