Tinder / bazel-diff

Performs Bazel Target Diffing between two revisions in Git, allowing for Test Target Selection and Selective Building
Other
405 stars 60 forks source link

[Feature Request] Bazel diff should honor external repos loaded in MODULE.bazel #255

Open tgeng opened 1 week ago

tgeng commented 1 week ago

Currently, if one loads an http_archive from MODULE.bazel and reference things from the loaded in a target, the generated hash does not capture parameters of this http_archive. Using --fineGrainedHashExternalRepos flag can work around this issue. But it can get costly.

Under the hood this is because bazel query //external:all-targets at here does not return any repos loaded from MODULE.bazel. One way to get the modules from MODULE.bazel is to use bazel mod dump_repo_mapping followed by bazel mod show_repo @repo1 @repo2. However, currently show_repo does not support outputting machine parsable output (tracked by https://github.com/bazelbuild/bazel/issues/21617).

This issue is just to track this feature. For now I can workaround the problem by feeding all the repos returned by bazel mod dump_repo_mapping to --fineGrainedHashExternalRepos to make this work.

tgeng commented 1 week ago

I guess an alternative way to populate this would be reading MODULE.bazel.lock.