Open jbedard opened 1 month ago
@fmeum can you confirm if adding this to the gazelle core is something we'd like to do? If so are there preferences for which library to use vs manual?
How is this different from using 'gazelle:exclude' directives?
People won't want to copy+paste gitignore files into BUILD files...?
Functionally gitignore also works a bit different with things like !
operators etc. That is one reason to use a library such as go-git
instead of doing it ourselves but we could also potentially do it ourselves but don't support !
...
I kind of like this as it reduces the amount of Gazelle-specific configuration.
I don't know which library is best, but we should definitely use one rather than roll our own.
I don't know which library is best, but we should definitely use one rather than roll our own.
I agree we should use a real library and not try to re-implement gitignore logic, otherwise we'll just end up with a never-ending stream "it doesn't work like git" bugs.
The go-git
library is what I've used in all the aspect gazelle extensions and I've never had any issues so I think that's a good place to start. If we add appropriate tests then we should be able to change the implementation later.
FWIW I've also tried other libraries which all had issues in the aspect gazelle extensions:
Those both also seem to be unmaintained.
Others I have not tried seem to also be unmaintained and many look too simple or slow:
This looks great to me, @fmeum wdyt?
What type of PR is this?
What package or component does this PR mostly affect?
What does this PR do? Why is it needed?
Allow users to opt-in to respecting the gitignore when collecting files for gazelle extensions to consume.
While bazel can access git-ignored files many repositories manually exclude git-ignored content by not including it in source file lists or globs in BUILDs or by duplicating the git-ignore entries as
# gazelle:exclude
.Ideally users would put all bazel ignored content in
.bazelignore
but without glob support that is often not done.This should remain opt-in for repositories wanting it but by default bazel can access git-ignored content so gazelle should as well.
Which issues(s) does this PR fix?
Fixes #1166
Other notes for review