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

Make sources: respect a new .taskignore file, similar to .gitignore #1753

Open
nikaro opened this issue Aug 11, 2024 · 4 comments · May be fixed by #1932
Open

Make sources: respect a new .taskignore file, similar to .gitignore #1753

nikaro opened this issue Aug 11, 2024 · 4 comments · May be fixed by #1932
Labels
area: fingerprinting Changes related to checksums and caching.

Comments

@nikaro
Copy link

nikaro commented Aug 11, 2024

I'm using this task to lint JSON files:

  json:
    desc: Lint JSON files
    sources:
      - ./**/*.json
      - exclude: .venv/**/*.json
    cmds:
      - for: sources
        cmd: jq empty {{.ITEM}}
      - for: sources
        cmd: prettier --check --parser json {{.ITEM}}

And it would be nice if sources could respect the .gitignore content instead of having to exclude all ignored patterns.

This is especially needed as i'm using this task from a Remote Taskfiles #1317 and cannot easily edit it.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Aug 11, 2024
@andreynering andreynering added type: enhancement and removed state: needs triage Waiting to be triaged by a maintainer. labels Aug 11, 2024
@andreynering
Copy link
Member

Respecting .gitignore is a nice suggestion. In theory it'd be a small breaking change, though, because some users may not expect it to be excluded.

Alternative, we could introduce a .taskignore, using the same format. Or, just have a global ignore: setting on the Taskfile that would be globally respected.

@nikaro
Copy link
Author

nikaro commented Aug 11, 2024

we could introduce a .taskignore, using the same format

This would be fine as it could be a symlink to .gitignore to avoid duplicating file content in case you want to ignore the same things.

have a global ignore: setting on the Taskfile that would be globally respected

For this one i think its value should be gitignore-like file to parse, maybe .taskignore by default, then it could be overridden (ex. with .gitignore) for those who do not want to add another file/symlink.

For the record, in the meantime my workaround is using fd [...] | xargs [...] as fd exclude .gitignore content by default. Ex:

  json:
    desc: Lint JSON files
    sources:
      - ./**/*.json
    cmds:
      - fd --hidden --extension json | xargs --no-run-if-empty jq empty
      - fd --hidden --extension json | xargs --no-run-if-empty prettier --check --parser json

@nikaro
Copy link
Author

nikaro commented Aug 11, 2024

I don't have much time right now to give this a try, but this lib could probably be used to help for gitignore parsing: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/format/gitignore

@vmaerten
Copy link
Member

Hey!
I think .taskignore is a good idea! I am not in favor reading .gitignore

@vmaerten vmaerten added the area: fingerprinting Changes related to checksums and caching. label Aug 12, 2024
@andreynering andreynering changed the title Sources should not include files in .gitignore Make sources: respect a new .taskignore file, similar to .gitignore Aug 12, 2024
@GeneTakavic24 GeneTakavic24 linked a pull request Nov 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: fingerprinting Changes related to checksums and caching.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants