feat: support excluding task namespaces (#2959)

This commit is contained in:
星尘
2026-08-10 22:23:51 +08:00
committed by GitHub
parent fc49c72647
commit 2888867c94
8 changed files with 78 additions and 10 deletions

View File

@@ -412,8 +412,10 @@ You can do this by using the
### Exclude tasks from being included
You can exclude tasks from being included by using the `excludes` option. This
option takes the list of tasks to be excluded from this include.
You can exclude tasks or entire namespaces from being included by using the
`excludes` option. This option takes the list of tasks or namespaces to be
excluded from this include. Task names are matched exactly. To exclude a
namespace, append `:*` to its name.
::: code-group
@@ -423,7 +425,7 @@ version: '3'
includes:
included:
taskfile: ./Included.yml
excludes: [foo]
excludes: [foo, 'internal:*', 'debug:*']
```
```yaml [Included.yml]
@@ -432,11 +434,14 @@ version: '3'
tasks:
foo: echo "Foo"
bar: echo "Bar"
internal:setup: echo "Internal setup"
debug:status: echo "Debug status"
```
:::
`task included:foo` will throw an error because the `foo` task is excluded but
`task included:foo`, `task included:internal:setup`, and
`task included:debug:status` will throw errors because they are excluded, but
`task included:bar` will work and display `Bar`.
It's compatible with the `flatten` option.

View File

@@ -308,13 +308,14 @@ includes:
### `excludes`
- **Type**: `[]string`
- **Description**: Tasks to exclude from inclusion
- **Description**: Task names or namespace patterns ending in `:*` to exclude
from inclusion
```yaml
includes:
shared:
taskfile: ./shared.yml
excludes: [internal-setup, debug-only]
excludes: [internal-setup, 'debug:*', 'experimental:*']
```
### `vars`

View File

@@ -746,7 +746,7 @@
}
},
"excludes": {
"description": "A list of tasks to be excluded from inclusion.",
"description": "A list of task names or namespace patterns ending in `:*` to be excluded from inclusion.",
"type": "array",
"items": {
"type": "string"