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

go_repository: avoid unnecessary fetches in HTTP mode #1206

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

blico
Copy link
Contributor

@blico blico commented Mar 18, 2022

Currently, if a go_repository rule is in HTTP mode and has build_file_generation = on it can result in unnecessary calls to download_and_extract while the @bazel_gazelle_go_repository_tools and @bazel_gazelle_go_repository_cache labels are still not available. Note that redundant fetches can be unavoidable when in HTTP mode and build_file_generation = auto because the rule needs to fetch and examine the repo to determine if it requires @bazel_gazelle_go_repository_tools.

For more info about repository rule restarting see:
https://docs.bazel.build/versions/5.0.0/skylark/repository_rules.html#when-is-the-implementation-function-executed

Resolve #1175

Copy link

@adam-azarchs adam-azarchs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this will help. Thanks!

internal/go_repository.bzl Show resolved Hide resolved
internal/go_repository.bzl Show resolved Hide resolved
@blico blico merged commit 7eb7a1f into bazel-contrib:master Mar 22, 2022
jfirebaugh added a commit to figma/bazel-gazelle that referenced this pull request Mar 13, 2023
See bazel-contrib#1175 and bazel-contrib#1206.

The pull request was conservative and only fixed restarts for repositories where it could be statically determined that `@bazel_gazelle_go_repository_tools//:bin/gazelle` was needed. It did not avoid restarts in the case where `go_repository` needs to fetch and examine the repo to determine if it requires `@bazel_gazelle_go_repository_tools`. But that's the common case for `go_repository`, so this patches the implementation to unconditionally require `@bazel_gazelle_go_repository_tools`.
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

Successfully merging this pull request may close these issues.

go_repository rule restarts
2 participants