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

Don't ignore files that have been added to a job's watch list #308

Open
irh opened this issue Jan 17, 2025 · 5 comments
Open

Don't ignore files that have been added to a job's watch list #308

irh opened this issue Jan 17, 2025 · 5 comments

Comments

@irh
Copy link
Contributor

irh commented Jan 17, 2025

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.

@Canop
Copy link
Owner

Canop commented Jan 17, 2025

This makes sense but it's not so obvious because you usually add whole dirs to watch.

What about this case ?

  • you add *.backup to your .gitignore because your IDE randomly creates such files
  • you then add amber-src because 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.

@irh
Copy link
Contributor Author

irh commented Jan 17, 2025

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 watch then 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-ignore then I think it should be watched while respecting .git-ignore rules for its contents.
    • So if I add amber-src, then nested *.backup files would be ignored, while watching other files that aren't ignored by .git-ignore.
    • If I wanted I could then add *.backup to watch to override .git-ignore.

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!

@Canop
Copy link
Owner

Canop commented Jan 17, 2025

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.

@irh
Copy link
Contributor Author

irh commented Jan 17, 2025

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?

@Canop
Copy link
Owner

Canop commented Jan 17, 2025

Yes. This specific example looks tedious but it looks, to me, more compatible with the ignore chain logic.

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

2 participants