bazel-contrib / bazel-gazelle

Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.19k stars 378 forks source link

feat: support only updating existing BUILD files #1921

Open jbedard opened 1 month ago

jbedard commented 1 month ago

Close #1832

What type of PR is this?

Feature

Other

What package or component does this PR mostly affect?

all

What does this PR do? Why is it needed?

Add an option to enable only updating existing BUILDs and not creating any new ones.

I think this is common among extension authors, normally implemented with a quick-exit within Configure if the *rule.File is nil. However all the subdirs then need to be manually traversed to find files in subdirectories with no BUILD.

I've always maintained a patch similar to this PR to avoid plugins having to do manual fs operations.

Which issues(s) does this PR fix?

Fixes #1832

Other notes for review