@@ -53,16 +53,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5353 return (mod && mod.__esModule) ? mod : { "default": mod };
5454};
5555Object.defineProperty(exports, "__esModule", ({ value: true }));
56- exports.Filter = void 0;
56+ exports.Filter = exports.isPredicateQuantifier = exports.SUPPORTED_PREDICATE_QUANTIFIERS = exports.PredicateQuantifier = void 0;
5757const jsyaml = __importStar(__nccwpck_require__(1917));
5858const picomatch_1 = __importDefault(__nccwpck_require__(8569));
5959// Minimatch options used in all matchers
6060const MatchOptions = {
6161 dot: true
6262};
63+ /**
64+ * Enumerates the possible logic quantifiers that can be used when determining
65+ * if a file is a match or not with multiple patterns.
66+ *
67+ * The YAML configuration property that is parsed into one of these values is
68+ * 'predicate-quantifier' on the top level of the configuration object of the
69+ * action.
70+ *
71+ * The default is to use 'some' which used to be the hardcoded behavior prior to
72+ * the introduction of the new mechanism.
73+ *
74+ * @see https://en.wikipedia.org/wiki/Quantifier_(logic)
75+ */
76+ var PredicateQuantifier;
77+ (function (PredicateQuantifier) {
78+ /**
79+ * When choosing 'every' in the config it means that files will only get matched
80+ * if all the patterns are satisfied by the path of the file, not just at least one of them.
81+ */
82+ PredicateQuantifier["EVERY"] = "every";
83+ /**
84+ * When choosing 'some' in the config it means that files will get matched as long as there is
85+ * at least one pattern that matches them. This is the default behavior if you don't
86+ * specify anything as a predicate quantifier.
87+ */
88+ PredicateQuantifier["SOME"] = "some";
89+ })(PredicateQuantifier || (exports.PredicateQuantifier = PredicateQuantifier = {}));
90+ /**
91+ * An array of strings (at runtime) that contains the valid/accepted values for
92+ * the configuration parameter 'predicate-quantifier'.
93+ */
94+ exports.SUPPORTED_PREDICATE_QUANTIFIERS = Object.values(PredicateQuantifier);
95+ function isPredicateQuantifier(x) {
96+ return exports.SUPPORTED_PREDICATE_QUANTIFIERS.includes(x);
97+ }
98+ exports.isPredicateQuantifier = isPredicateQuantifier;
6399class Filter {
64100 // Creates instance of Filter and load rules from YAML if it's provided
65- constructor(yaml) {
101+ constructor(yaml, filterConfig) {
102+ this.filterConfig = filterConfig;
66103 this.rules = {};
67104 if (yaml) {
68105 this.load(yaml);
@@ -89,7 +126,16 @@ class Filter {
89126 return result;
90127 }
91128 isMatch(file, patterns) {
92- return patterns.some(rule => (rule.status === undefined || rule.status.includes(file.status)) && rule.isMatch(file.filename));
129+ var _a;
130+ const aPredicate = (rule) => {
131+ return (rule.status === undefined || rule.status.includes(file.status)) && rule.isMatch(file.filename);
132+ };
133+ if (((_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.predicateQuantifier) === 'every') {
134+ return patterns.every(aPredicate);
135+ }
136+ else {
137+ return patterns.some(aPredicate);
138+ }
93139 }
94140 parseFilterItemYaml(item) {
95141 if (Array.isArray(item)) {
@@ -528,11 +574,18 @@ async function run() {
528574 const filtersYaml = isPathInput(filtersInput) ? getConfigFileContent(filtersInput) : filtersInput;
529575 const listFiles = core.getInput('list-files', { required: false }).toLowerCase() || 'none';
530576 const initialFetchDepth = parseInt(core.getInput('initial-fetch-depth', { required: false })) || 10;
577+ const predicateQuantifier = core.getInput('predicate-quantifier', { required: false }) || filter_1.PredicateQuantifier.SOME;
531578 if (!isExportFormat(listFiles)) {
532579 core.setFailed(`Input parameter 'list-files' is set to invalid value '${listFiles}'`);
533580 return;
534581 }
535- const filter = new filter_1.Filter(filtersYaml);
582+ if (!(0, filter_1.isPredicateQuantifier)(predicateQuantifier)) {
583+ const predicateQuantifierInvalidErrorMsg = `Input parameter 'predicate-quantifier' is set to invalid value ` +
584+ `'${predicateQuantifier}'. Valid values: ${filter_1.SUPPORTED_PREDICATE_QUANTIFIERS.join(', ')}`;
585+ throw new Error(predicateQuantifierInvalidErrorMsg);
586+ }
587+ const filterConfig = { predicateQuantifier };
588+ const filter = new filter_1.Filter(filtersYaml, filterConfig);
536589 const files = await getChangedFiles(token, base, ref, initialFetchDepth);
537590 core.info(`Detected ${files.length} changed files`);
538591 const results = filter.match(files);
0 commit comments