Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude doesn't support globbing #1602

Closed
polds opened this issue Apr 18, 2024 · 1 comment
Closed

Exclude doesn't support globbing #1602

polds opened this issue Apr 18, 2024 · 1 comment

Comments

@polds
Copy link

polds commented Apr 18, 2024

  • Task version: v3.36.0 (h1:XVJ5hQ5hdzTAulHpAGzbUMUuYr9MUOEQFOFazI3hUsY=)
  • Operating system: macOS
  • Experiments enabled: None

It looks like exclude does not support globbing, the docs don't explicitly mention that it does (or doesn't), so maybe this is by-design? But I would expect to be able to declare globbed exclusions (generated files, whole directories, etc)

You can see a small example here by utilizing a loop over sources:

# directory structure
for d in "1" "2" "3"; do mkdir $d; done
# files
for f in "a.txt" "a.go" "1/b_gen.go" "2/c.go" "3/d.go"; do touch $f; done

Taskfile.yaml

version: '3'

tasks:
  default:
    sources:
      - "**/*.go"
      - "exclude: **/*_gen.go" # Try to exclude all files ending with _gen.go
      - "exclude: 3/**/*.go"   # Try to exclude an entire directory
    cmds:
      - for: sources
        cmd: echo {{.ITEM}}

Result

$ task --force
task: [default] echo 1/b_gen.go
1/b_gen.go
task: [default] echo 2/c.go
2/c.go
task: [default] echo 3/d.go
3/d.go
task: [default] echo a.go
a.go

What I would expect based on the excludes:

  • task: [default] echo 1/b_gen.go is not executed due to exclude: **/*_gen.go
  • task: [default] echo 3/d.go is not executed due to exclude: 3/**/*.go

If I add exclude: 3/d.go it does correctly exclude it from the output.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Apr 18, 2024
@pd93
Copy link
Member

pd93 commented Apr 26, 2024

Hey @polds. Thanks for the excellent repro steps. Took me a second to figure out what was wrong, but it's as simple as unquoting "exclude: ...". exclude should be an actual YAML key rather than a part of the glob string.

Working example below:

version: '3'

tasks:
  default:
    sources:
      - "**/*.go"
      - exclude: "**/*_gen.go" # Try to exclude all files ending with _gen.go
      - exclude: "3/**/*.go"   # Try to exclude an entire directory
    cmds:
      - for: sources
        cmd: echo {{.ITEM}}

@pd93 pd93 closed this as completed Apr 26, 2024
@pd93 pd93 added type: question Further information is requested. and removed state: needs triage Waiting to be triaged by a maintainer. labels Apr 26, 2024
@pd93 pd93 removed the type: question Further information is requested. label Dec 15, 2024
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

No branches or pull requests

3 participants