refactor(dev-infra): Add support for groups in the conditions evaluator (#38164)
Conditions can refer to the groups array that is a list of the preceding groups. This commit adds support to the verification for those conditions. This commit also adds some tests to the parsing and condition matching to ensure everything works as expected. PR Close #38164
This commit is contained in:

committed by
Misko Hevery

parent
200dbd4860
commit
5e89d98876
24
dev-infra/pullapprove/utils.ts
Normal file
24
dev-infra/pullapprove/utils.ts
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {IMinimatch, Minimatch} from 'minimatch';
|
||||
|
||||
/** Map that holds patterns and their corresponding Minimatch globs. */
|
||||
const patternCache = new Map<string, IMinimatch>();
|
||||
|
||||
/**
|
||||
* Gets a glob for the given pattern. The cached glob will be returned
|
||||
* if available. Otherwise a new glob will be created and cached.
|
||||
*/
|
||||
export function getOrCreateGlob(pattern: string) {
|
||||
if (patternCache.has(pattern)) {
|
||||
return patternCache.get(pattern)!;
|
||||
}
|
||||
const glob = new Minimatch(pattern, {dot: true});
|
||||
patternCache.set(pattern, glob);
|
||||
return glob;
|
||||
}
|
Reference in New Issue
Block a user