You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 07b31db
Browse filesBrowse the repository at this point in the historyBrowse files
feat(discovery)!: match exclude patterns with picomatch under an owned glob grammar
The exclude discovery filter compiled its own RegExp from each pattern, with "*" the only operator and every other character literal. Each pattern is now compiled once at the input boundary with picomatch (the posix entry, nocase, dot, posix classes, no fast paths, debug), and the boundary owns the grammar: name characters, at most one "/", "*", "?", "[abc]", "[!abc]" or "[^abc]", and one leading "!". Anything else is refused when the inputs are parsed, naming the written pattern, the reason, and the fix, because the pattern is the user's input and because picomatch reads braces, parentheses, quotes, backslashes, a leading "./", and a run of stars as regex syntax through paths no option closes, compiling a wrong or never-matching filter silently.
DiscoveryFilters.exclude carries the compiled ExcludePattern (pattern, scope, regex) instead of strings, so a config built from argv still equals one built from the environment, and compileExcludePattern with ExcludePattern join the library surface. The e2e oracle's independent matcher learns "?" and a leading "!", and two scenarios pin the new forms end to end. The upgrading guide gains section 61.
BREAKING CHANGE: In an exclude pattern, "?" now matches one character, "[abc]" and "[!abc]" are classes, and a leading "!" negates the pattern; each matched nothing before, so a pattern that relied on one of them matching literally is deleted and one that meant a glob is rewritten in that grammar. A leading "./" (drop it), a run of stars (write one "*"), surrounding whitespace from a library caller (trim it), a "." or ".." side, a second "/", a doubled "!", and any regex token ("(a)+", "\d", "{a..b}", quotes) fail the run naming the fix. Library callers supply exclude as ExcludePattern values from compileExcludePattern instead of strings.
Copy file name to clipboardExpand all lines: docs/operate/multi-repo.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,10 @@ Discovery takes six filter inputs that apply only to `repos: "*"`; setting any o
57
57
- `archived` defaults to `skip`, because settings writes fail on archived repositories; `archived: only` is mostly useful with `mode: check`.
58
58
- `forks`includes, excludes, or keeps only forks.
59
59
- `topics`keeps repositories carrying at least one listed topic, so a single marker topic can opt repositories in. It is unrelated to the `topics` settings section.
60
-
- `exclude` takes wildcard patterns where `*` matches anything: a pattern containing `/` is matched against the full `owner/name`, any other against the name alone, case-insensitively.
60
+
- `exclude` takes glob patterns, matched case-insensitively: a pattern containing `/` against the full `owner/name`, any other against the name alone.
61
+
- `*`matches any run of characters, `?` one character, `[abc]` one of a set, `[!abc]` or `[^abc]` one outside it.
62
+
- One leading `!` negates the pattern, so `!svc-*` drops everything except the services.
63
+
- Beyond those operators a pattern holds only name characters (letters, digits, `.`, `-`, `_`), at most one `/` with a non-empty glob on each side, and no side that is just `.` or `..`. Anything else (a leading `./`, a run of stars, a brace, a parenthesis, a backslash, a quote, a second `/`, a class holding `*`) fails the run before discovery starts, naming the fix, as does a class like `[z-a]`. The matcher is [picomatch](https://github.com/micromatch/picomatch), confined to that grammar.
61
64
- `affiliation` selects which relationships to the token's user qualify, passed to GitHub's `/user/repos` listing: `owner`(the default), `collaborator`, or `organization_member`. The list replaces the default, so widening discovery beyond owned repositories takes `owner,collaborator`.
62
65
63
66
## Fallback for repositories without a settings file
Copy file name to clipboardExpand all lines: docs/reference/inputs.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ A list input (`sections`, `required-sections`, `repos`, `exclude`, `topics`, `af
38
38
|`visibility`| <p>Keeps only repositories of this visibility in repos: "*" discovery: all (default), public, private, or internal.</p> |`false`|`""`|
39
39
|`archived`| <p>Archived-repository policy for repos: "*" discovery: skip (default), include, or only.</p> |`false`|`""`|
40
40
|`forks`| <p>Fork policy for repos: "*" discovery: include (default), exclude, or only.</p> |`false`|`""`|
41
-
|`exclude`| <p>Comma- or newline-separated wildcard patterns removing repositories from repos: "*" discovery.</p> |`false`|`""`|
41
+
|`exclude`| <p>Comma- or newline-separated glob patterns removing repositories from repos: "*" discovery, compared case-insensitively against owner/name when the pattern has a "/" and against the name alone otherwise. A star matches any run of characters, "?" one character, "[abc]" one of a set, "[!abc]" or "[^abc]" one outside it, and one leading "!" negates the pattern. Beyond those a pattern holds only letters, digits, ".", "-", and "_", with at most one "/", nothing empty around it, and no side that is just "." or ".."; anything else (a leading "./", a run of stars, a regex token such as "(a)+") fails the run naming the fix.</p> |`false`|`""`|
42
42
|`topics`| <p>Comma- or newline-separated topics, of which repos: "*" discovery keeps the repositories carrying at least one.</p> |`false`|`""`|
43
43
|`affiliation`| <p>Comma- or newline-separated affiliations for repos: "*" discovery: owner (default), collaborator, or organization_member.</p> |`false`|`""`|
|`discoverRepos`| function | The repositories a token can see, filtered |
247
247
|`DiscoveryFilters`| type | The filters: `visibility`, `archived`, `forks`, `affiliation`, `topics`, `exclude`|
248
248
|`DEFAULT_DISCOVERY_FILTERS`| const | The action's defaults |
249
+
|`compileExcludePattern`| function | One `exclude` glob compiled once, or the problem naming why it is unusable and the fix |
250
+
|`ExcludePattern`| type | A compiled `exclude` entry: the operator's text, the scope its slash chose, and the regex |
249
251
|`parseReposInput`| function | The `repos` input form: slugs, or `"*"` for discovery |
250
252
|`resolveCentralTargets`| function | The `<owner>/<name>.yml` files of a repos-dir as targets, with warnings for the files it skipped |
251
253
|`dedupeTargets`| function | Merge the central and the remote targets, central first; a remote target whose slug a central one already names is dropped with a notice |
Fix: add `tryList` to every `GitHubClient` double: answer the pages your `tryRequest` route table would (`per_page=N&page=K` from 1, until a page is short) and return their bodies as `{ data: [...] }`; a client over another transport returns each page's body as received, and honors `until` by stopping after the first page it accepts.
1283
1283
1284
+
## 61. Discovery: `exclude` patterns are globs under an owned grammar
1285
+
1286
+
For every `repos: "*"` workflow that sets `exclude`, and for `@vivswan/github-settings-as-code` consumers building `DiscoveryFilters`. In v2 an `exclude` pattern knew one operator, `*`, and matched every other character literally, so a `?`, a `[`, or a leading `!` could only ever match nothing. In v3 the pattern is a glob matched by picomatch inside a grammar the input boundary owns: `*` any run of characters, `?` one character, `[abc]` one of a set, `[!abc]` or `[^abc]` one outside it, one leading `!` negating the whole pattern, and beyond those only name characters (letters, digits, `.`, `-`, `_`) with at most one `/`. The scope rule is unchanged: a pattern with `/` matches `owner/name`, any other the name alone, case-insensitively.
1287
+
1288
+
Two kinds of pattern move:
1289
+
1290
+
- A pattern that gains glob meaning: `tmp-?`, `svc-[ab]`, `!svc-*`. Each matched nothing in v2; in v3 `!svc-*` excludes every repository that is not a service.
1291
+
- A pattern outside the grammar fails the run before discovery starts, naming the fix: a leading `./` (drop it), a run of stars (write one `*`), a `.` or `..` side (`x/..`), a second `/`, a doubled `!!`, or a regex token (`(a)+`, `\d`, `{a..b}`, a quote). The pattern is your input, so it is refused, never repaired.
1292
+
1293
+
```text
1294
+
v2 exclude: "!svc-*" -> matched nothing, every repository discovered
1295
+
v3 exclude: "!svc-*" -> excludes every repository whose name is not svc-*
v3 exclude: "./tmp-**" -> error: the "exclude" input pattern "./tmp-**" is not a usable glob: it starts with "./", which names no owner, so drop every leading "./", and it holds a run of stars, which matches no more than one "*" does, so write one "*". Write ...
1300
+
1301
+
v3 exclude: "svc-(a)+" -> error: the "exclude" input pattern "svc-(a)+" is not a usable glob: it holds "(", ")", "+", which no owner or repository name contains, so remove them. Write ...
1302
+
```
1303
+
1304
+
Fix: delete a pattern that relied on `?`, `[`, `]`, or `!` matching literally, since it never matched a repository; rewrite one that meant a glob in the grammar above, following the fix each refusal names.
1305
+
1306
+
For library callers, `DiscoveryFilters.exclude` takes compiled `ExcludePattern` values instead of strings: run each pattern through `compileExcludePattern` at your input boundary.
1. Rename any settings file whose path contains a comma, rename `undeclared` to `_undeclared` in every settings file, and move every other underscore key into a YAML comment; the v2 line accepts the old spellings only, so do all three together with the pin move.
0 commit comments