Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 42c873d

Browse files
authored
Fix pathfilter (#33)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI **Bug fix:** Fixed issues with the `PathFilter` class. Refactored the class to ensure that if there are no inclusion rules, all paths are included by default. Additionally, the code now correctly handles cases where both inclusion and exclusion rules exist for a given path. These changes should improve the reliability of the code. <!-- end of auto-generated comment: release notes by openai -->
1 parent c95e4f3 commit 42c873d

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

action.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,22 @@ inputs:
3131
- https://github.com/isaacs/minimatch
3232
default: |
3333
!dist/**
34-
!**/*.pb.go
35-
!**/*.lock
36-
!**/*.yaml
37-
!**/*.yml
38-
!**/*.cfg
39-
!**/*.ini
40-
!**/*.mod
41-
!**/*.sum
42-
!**/*.json
43-
!**/*.mmd
44-
!**/*.svg
45-
!**/*.png
46-
!**/*.dot
34+
!*.pb.go
35+
!*.lock
36+
!*.yaml
37+
!*.yml
38+
!*.cfg
39+
!*.toml
40+
!*.ini
41+
!*.mod
42+
!*.sum
43+
!*.json
44+
!*.mmd
45+
!*.svg
46+
!*.png
47+
!*.dot
4748
!**/gen/**
49+
!**/_gen/**
4850
!**/vendor/**
4951
system_message:
5052
required: false

dist/index.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/options.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,27 @@ export class PathFilter {
191191
}
192192

193193
check(path: string): boolean {
194-
let include_all = this.rules.length === 0
195-
let matched = false
194+
if (this.rules.length === 0) {
195+
return true
196+
}
197+
198+
let included = false
199+
let excluded = false
200+
let inclusionRuleExists = false
201+
196202
for (const [rule, exclude] of this.rules) {
197-
if (exclude) {
198-
if (minimatch(path, rule)) {
199-
return false
200-
}
201-
include_all = true
202-
} else {
203-
if (minimatch(path, rule)) {
204-
matched = true
205-
include_all = false
203+
if (minimatch(path, rule)) {
204+
if (exclude) {
205+
excluded = true
206206
} else {
207-
return false
207+
included = true
208208
}
209209
}
210+
if (!exclude) {
211+
inclusionRuleExists = true
212+
}
210213
}
211-
return include_all || matched
214+
215+
return (!inclusionRuleExists || included) && !excluded
212216
}
213217
}

0 commit comments

Comments
 (0)