Skip to content

Commit

Permalink
fix(build-tools): Filter out empty responses from git ls-files (#22247)
Browse files Browse the repository at this point in the history
#22226 introduced a bug that caused directory paths to get into the list
of cached files in the Biome task. The root cause was incomplete
handling of the response from `git ls-files`. Empty strings made it into
the list of files, which later resolved as a path to the working
directory - the root of the repo.

The fix is to remove empty strings from the results array.
  • Loading branch information
tylerbutler authored Aug 17, 2024
1 parent f461368 commit 6f4b15d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion build-tools/packages/build-cli/src/library/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,13 @@ export class Repository {

// This includes paths to deleted, unstaged files, so we get the list of deleted files from git status and remove
// those from the full list.
const allFiles = new Set(results.split("\n").map((line) => line.trim()));
const allFiles = new Set(
results
.split("\n")
.map((line) => line.trim())
// filter out empty lines
.filter((line) => line !== ""),
);
const status = await this.gitClient.status();
for (const deletedFile of status.deleted) {
allFiles.delete(deletedFile);
Expand Down
8 changes: 7 additions & 1 deletion build-tools/packages/build-tools/src/common/gitRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,13 @@ export class GitRepo {

// This includes paths to deleted, unstaged files, so we get the list of deleted files from git status and remove
// those from the full list.
const allFiles = new Set(fileResults.split("\n").map((line) => line.trim()));
const allFiles = new Set(
fileResults
.split("\n")
.map((line) => line.trim())
// filter out empty lines
.filter((line) => line !== ""),
);

for (const deletedFile of deletedFiles) {
allFiles.delete(deletedFile);
Expand Down

0 comments on commit 6f4b15d

Please sign in to comment.