Skip to content

Commit

Permalink
update diffFilter D to get all the deleted throughout history
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Dec 4, 2024
1 parent 2bd8e85 commit 7f10c6b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/dev/create-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,33 @@ const getDiffFilesFromFirstCommit = async ({
projectPath: string;
diffFilter?: "d" | "D";
}): Promise<string[]> => {
if (diffFilter === "D") {
// all files that have ever existed in the repo's history
const { stdout: allFiles } = await execa(
"git",
["log", "--all", "--diff-filter=ACDMRT", "--name-only", "--format="],
{ cwd: projectPath },
);

const { stdout: currentFiles } = await execa("git", ["ls-files"], {
cwd: projectPath,
});

const allFilesSet = new Set(allFiles.split("\n").filter(Boolean));
const currentFilesSet = new Set(currentFiles.split("\n").filter(Boolean));

return Array.from(allFilesSet).filter(file => !currentFilesSet.has(file));
}

const { stdout: firstCommit } = await execa("git", ["rev-list", "--max-parents=0", "HEAD"], {
cwd: projectPath,
});

const diffFilterArg = diffFilter ? `--diff-filter=${diffFilter}` : "";
const { stdout } = await execa("git", ["diff", diffFilterArg, "--name-only", `${firstCommit.trim()}..HEAD`], {
cwd: projectPath,
});

return stdout.split("\n").filter(Boolean);
};

Expand Down

0 comments on commit 7f10c6b

Please sign in to comment.