Skip to content

feat: support excluding task namespaces - #2959

Merged
vmaerten merged 2 commits into
go-task:mainfrom
xmxxc:fix/exclude-task-namespaces
Aug 10, 2026
Merged

feat: support excluding task namespaces#2959
vmaerten merged 2 commits into
go-task:mainfrom
xmxxc:fix/exclude-task-namespaces

Conversation

@xmxxc

@xmxxc xmxxc commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Allow includes.excludes entries ending in :* to exclude entire task namespaces.
  • Preserve exact task-name matching for entries without :*.
  • Scope namespace exclusions to descendants: foo:* excludes foo:child, but not the standalone foo task or tasks in similarly prefixed namespaces such as foo-other.
  • Add coverage for exact task matching and namespace exclusions with regular and flattened includes.
  • Update the guide, schema reference, and public JSON Schema description.

Testing

  • go test ./... -run '^TestIncludesWithExclude$' -count=1
  • go test ./taskfile/... -count=1
  • go vet ./...

AI Assistance

AI assistance was used to review the changes. During the review, it identified that the excludes description in the public JSON Schema had not been updated to mention namespaces. I reviewed and fixed the inconsistency before submitting this pull request.

Fixes #2300

@vmaerten vmaerten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this

I know it's not like this in the issue but can you make excludes entries match task names exactly, and require a trailing :* for a namespace? So excludes: [debug] only excludes a task named debug, while excludes: ['debug:*'] excludes everything under it.

Two reasons:

  • Everywhere else in Task a task name means exactly that task. A bare name here would silently change behaviour for anyone who has both a deploy task and a deploy: namespace, which would be misleading for our users.
  • It also keeps the door open for the glob/regex support if we want to add it later

The rest looks good
Happy to push these changes myself if you prefer.

Comment thread taskfile/ast/tasks.go Outdated
@vmaerten vmaerten self-assigned this Aug 9, 2026
@xmxxc

xmxxc commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback and for offering to help! I've applied the requested changes in 15648b46:

  • Entries without :* now match task names exactly.
  • Namespace exclusions require a trailing :* and only match tasks within that namespace, so foo:* does not exclude the standalone foo task or tasks under similarly prefixed namespaces.
  • The matching logic has been moved to (*Include).isTaskExcluded in taskfile/ast/include.go.
  • Tests and documentation have been updated accordingly.

The following checks all pass locally:

  • go test ./... -run '^TestIncludesWithExclude$' -count=1
  • go test ./taskfile/... -count=1
  • go vet ./...

Please take another look when you have a chance.

@vmaerten vmaerten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

@vmaerten
vmaerten merged commit 2888867 into go-task:main Aug 10, 2026
16 checks passed
vmaerten added a commit that referenced this pull request Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for excluding entire namespaces in addition to individual tasks

2 participants