diff --git a/action.yml b/action.yml index 99474c4d..658c3475 100644 --- a/action.yml +++ b/action.yml @@ -31,20 +31,22 @@ inputs: - https://github.com/isaacs/minimatch default: | !dist/** - !**/*.pb.go - !**/*.lock - !**/*.yaml - !**/*.yml - !**/*.cfg - !**/*.ini - !**/*.mod - !**/*.sum - !**/*.json - !**/*.mmd - !**/*.svg - !**/*.png - !**/*.dot + !*.pb.go + !*.lock + !*.yaml + !*.yml + !*.cfg + !*.toml + !*.ini + !*.mod + !*.sum + !*.json + !*.mmd + !*.svg + !*.png + !*.dot !**/gen/** + !**/_gen/** !**/vendor/** system_message: required: false diff --git a/dist/index.js b/dist/index.js index 28fb863b..0492093d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -28736,26 +28736,26 @@ class PathFilter { } } check(path) { - let include_all = this.rules.length === 0; - let matched = false; + if (this.rules.length === 0) { + return true; + } + let included = false; + let excluded = false; + let inclusionRuleExists = false; for (const [rule, exclude] of this.rules) { - if (exclude) { - if (minimatch(path, rule)) { - return false; - } - include_all = true; - } - else { - if (minimatch(path, rule)) { - matched = true; - include_all = false; + if (minimatch(path, rule)) { + if (exclude) { + excluded = true; } else { - return false; + included = true; } } + if (!exclude) { + inclusionRuleExists = true; + } } - return include_all || matched; + return (!inclusionRuleExists || included) && !excluded; } } diff --git a/src/options.ts b/src/options.ts index d5b9346b..637a95b5 100644 --- a/src/options.ts +++ b/src/options.ts @@ -191,23 +191,27 @@ export class PathFilter { } check(path: string): boolean { - let include_all = this.rules.length === 0 - let matched = false + if (this.rules.length === 0) { + return true + } + + let included = false + let excluded = false + let inclusionRuleExists = false + for (const [rule, exclude] of this.rules) { - if (exclude) { - if (minimatch(path, rule)) { - return false - } - include_all = true - } else { - if (minimatch(path, rule)) { - matched = true - include_all = false + if (minimatch(path, rule)) { + if (exclude) { + excluded = true } else { - return false + included = true } } + if (!exclude) { + inclusionRuleExists = true + } } - return include_all || matched + + return (!inclusionRuleExists || included) && !excluded } }