Added the include pattern matching feature to the gh action

This commit is contained in:
Jimmy Royer 2024-09-05 17:57:16 -04:00
parent 89a44f2d65
commit 49d90aa697
9 changed files with 73 additions and 22 deletions

View file

@ -247,12 +247,26 @@ async function main() {
const excludePatterns = core
.getInput("exclude")
.split(",")
.map((s) => s.trim());
.map((s) => s.trim())
.filter((s) => s.length > 0); // Filter out empty strings;
const includePatterns = core
.getInput("include")
.split(",")
.map((s) => s.trim())
.filter((s) => s.length > 0); // Filter out empty strings;
const filteredDiff = parsedDiff.filter((file) => {
return !excludePatterns.some((pattern) =>
minimatch(file.to ?? "", pattern)
);
const excluded: boolean =
excludePatterns.length > 0 &&
excludePatterns.some((pattern) => minimatch(file.to ?? "", pattern));
const included: boolean =
includePatterns.length === 0 ||
includePatterns.some((pattern) => minimatch(file.to ?? "", pattern));
// Exluded patterns take precedence over included patterns.
return !excluded && included;
});
const comments = await analyzeCode(filteredDiff, prDetails);