mirror of
https://github.com/actions/labeler.git
synced 2025-12-14 13:47:02 +00:00
Add any and all functions for both checks
This commit is contained in:
@@ -40,7 +40,7 @@ export function getBranchName(branchBase: BranchBase): string | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
export function checkBranch(
|
||||
export function checkAnyBranch(
|
||||
regexps: string[],
|
||||
branchBase: BranchBase
|
||||
): boolean {
|
||||
@@ -63,6 +63,29 @@ export function checkBranch(
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkAllBranch(
|
||||
regexps: string[],
|
||||
branchBase: BranchBase
|
||||
): boolean {
|
||||
const branchName = getBranchName(branchBase);
|
||||
if (!branchName) {
|
||||
core.debug(` no branch name`);
|
||||
return false;
|
||||
}
|
||||
|
||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
||||
const matchers = regexps.map(regexp => new RegExp(regexp));
|
||||
for (const matcher of matchers) {
|
||||
if (!matchBranchPattern(matcher, branchName)) {
|
||||
core.debug(` "branch" patterns matched against ${branchName}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "branch" patterns did not match against ${branchName}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
function matchBranchPattern(matcher: RegExp, branchName: string): boolean {
|
||||
core.debug(` - ${matcher}`);
|
||||
if (matcher.test(branchName)) {
|
||||
|
||||
Reference in New Issue
Block a user