Skip to content

Commit

Permalink
Revert "Have a single isMatch for checking changed files"
Browse files Browse the repository at this point in the history
This reverts commit d4d4a10.
  • Loading branch information
joshdales committed May 5, 2023
1 parent 68a2598 commit 11812c3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/changedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,21 @@ function printPattern(matcher: Minimatch): string {
return (matcher.negate ? '!' : '') + matcher.pattern;
}

function isMatch(changedFile: string, matchers: Minimatch[]): boolean {
function isAnyMatch(changedFile: string, matchers: Minimatch[]): boolean {
core.debug(` matching patterns against file ${changedFile}`);
for (const matcher of matchers) {
core.debug(` - ${printPattern(matcher)}`);
if (matcher.match(changedFile)) {
core.debug(` ${printPattern(matcher)} matched`);
return true;
}
}

core.debug(` no patterns matched`);
return false;
}

function isAllMatch(changedFile: string, matchers: Minimatch[]): boolean {
core.debug(` matching patterns against file ${changedFile}`);
for (const matcher of matchers) {
core.debug(` - ${printPattern(matcher)}`);
Expand All @@ -69,7 +83,7 @@ export function checkAnyChangedFiles(
): boolean {
const matchers = globs.map(g => new Minimatch(g));
for (const changedFile of changedFiles) {
if (isMatch(changedFile, matchers)) {
if (isAnyMatch(changedFile, matchers)) {
core.debug(` "any" patterns matched against ${changedFile}`);
return true;
}
Expand All @@ -85,7 +99,7 @@ export function checkAllChangedFiles(
): boolean {
const matchers = globs.map(g => new Minimatch(g));
for (const changedFile of changedFiles) {
if (!isMatch(changedFile, matchers)) {
if (!isAllMatch(changedFile, matchers)) {
core.debug(` "all" patterns did not match against ${changedFile}`);
return false;
}
Expand Down

0 comments on commit 11812c3

Please sign in to comment.