Don't ignore files that have been added to a job's watch list
I'm doing some interactive testing on a temp file that I don't want to commit, using a file name that's in my global .gitignore.
So, I have a job where I've added the file to the watch list, and then I'd like it if GitIgnorer would make an exception for the explicitly watched file, instead of telling the watcher that it's OK to ignore it.
This makes sense but it's not so obvious because you usually add whole dirs to watch.
What about this case ?
- you add
*.backupto your .gitignore because your IDE randomly creates such files - you then add
amber-srcbecause that's where the language you use bacon for stores its source files
If you decide to ignore all *.backup in amber-src, you make a mess.
I feel like we should rather leverage the ignore field and allow negative patterns.
I'm sure I haven't fully thought this through, but with my user hat on I guess I would expect:
- If I've explicitly listed something in
watchthen it should override .git-ignore. - If it's a specific file then it should be watched, no questions asked.
- If I list a directory that's in
.git-ignorethen I think it should be watched while respecting.git-ignorerules for its contents.- So if I add
amber-src, then nested*.backupfiles would be ignored, while watching other files that aren't ignored by.git-ignore. - If I wanted I could then add
*.backuptowatchto override.git-ignore.
- So if I add
I feel like we should rather leverage the ignore field and allow negative patterns.
If there's an easy way to do this for a single file then I'm all for it!
What I propose is to support having negative patterns like this
ignore = [
"!myfiles"
]
in your job for the files that are in a .gitignore or a .ignore file but should be watched nevertheless.
I think I get it, so in my case I would have:
watch = ["myfile.txt"] # Watch a non-standard file that's in .gitignore
ignore = ["!myfile.txt"] # Override .gitignore
Is that right?
Yes. This specific example looks tedious but it looks, to me, more compatible with the ignore chain logic.
As an example of a concrete case I would use this for, .env files are pretty common to put in .gitignore since they may contain secrets/tokens etc., but it would be great to have bacon automatically reload a job when the .env file changes.
I wonder if adding a file to watch could just automatically add a !file entry in the ignore list for convenience to avoid the "double" configuration like that... It might be a little too magic (or cause weird other side effects) but seems like it would be more intuitive than the example above.