Split imports for directory strategy in buf generate
This is still WIP, but it seems to work with the base case.
Fixes https://github.com/bufbuild/buf/issues/3056, the problem where only non-imports are split by directory in buf generate. The original issue has a great description and repro.
Note, this cannot be achieved by simply removing the import check here, because the split images will conflate IsImport with whether we want to generate a file if permitted by include-imports. The latter is introduced to a new type ImageFileForGeneration.
TODOs:
- [ ] add more detailed tests
- [x] cleanup the code
- [ ] there are still places (
*_test.goand.../alpha/protoc/plugin.go) that callImageByDir, they should stop calling it. - [ ] Now their are functions that call
ImageByDir(the current implementation) and those that callImageByDirSplitImports, perhaps we can completely get rid ofImageByDir. - [ ] Perhaps move
bufimagegenerateintobufgen
This also refactors some generation-specific functions/types into a new bufimagegnerate package, lots of moving around. I will add comments indicating which changes are new code and which ones are relocation.
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
| Build | Format | Lint | Breaking | Updated (UTC) |
|---|---|---|---|---|
✅ passed | ✅ passed | ✅ passed | ✅ passed | Aug 21, 2024, 5:54 PM |
@doriable didn't I have a partial PR for this? Is this using that?
Should we close this now?
Yes, chatted with @doriable, we can close this one now.