-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[8.5.0] Support checking out the repo's default branch in git_repository/new_git_repository rule
#27705
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
[8.5.0] Support checking out the repo's default branch in git_repository/new_git_repository rule
#27705
Conversation
…ew_git_repository` rule The `git_repository` and `new_git_repository` rules currently require not only the remote repository URI to be specified but also either the branch, tag or revision (commit) to check out. This PR removes the latter requirement. If no branch, tag or revision are specified, the repo's default branch will be checked out. The main reason for introducing this proposed change, is because I noticed certain Bazel rules already generate `git_repository` targets from git URIs or other git repo specs that might not have a branch, tag or revision specified. These rules then typically default to a branch name of `master`, which is not correct in general. This change will allow those rules to simply omit the branch, tag and revision from the generated `git_repository` targets, to check out the repo's default branch. An alternative, more explicit, interface for specifying that the default branch is to be checked out, would have been to add an optional boolean `default_branch` attribute to the `git_repository` and `new_git_repository` rules. The presence of that attribute would be mutually exclusive with the presence of `branch`, `tag` and `commit`. Let me know if that interface is preferable. Addresses issue bazelbuild#27610. Closes bazelbuild#27611. PiperOrigin-RevId: 833710273 Change-Id: I7bc18efcbcfcaba61bf27052fecceb50336d2eb3
|
@fmeum @meteorcloudy There are presubmit failures. Could you please take a look? Thanks! |
|
@Pagten Can you please take a look at the test failure? |
|
The issue is in the This one-line change should fix the test (I verified this locally): How should I go about getting this change into the |
|
@Pagten Thanks for fixing this and sending the PR! I'll merge this once since it has a slightly better commit message. |
|
Sounds good. I'll close the other PR. |
39e9c72
This upgrade brings several performance improvements and bug fixes: #### Performance improvements - remote execution: bazelbuild/bazel#27564 - module extensions: bazelbuild/bazel#27296 #### Reliability improvements - cache invalidation: bazelbuild/bazel#27417 - configuration: bazelbuild/bazel#27128 - Git repositories: bazelbuild/bazel#27705 - query: - bazelbuild/bazel#27560 - bazelbuild/bazel#27117 - registry mirrors: bazelbuild/bazel#27531 #### Bug fixes - remote cache: bazelbuild/bazel#27996 - repository handling: bazelbuild/bazel#27995 - repository cache: bazelbuild/bazel#28161 - local execution: bazelbuild/bazel#27994
This upgrade brings several performance improvements and bug fixes: ## Performance improvements (8.5.0) - Remote execution: Add --remote_max_concurrency_per_connection flag to control concurrent gRPC requests (default: 100) bazelbuild/bazel#27564 - Module extensions: Support storing/retrieving JSON-like Starlark objects without invalidation, reducing unnecessary rebuilds bazelbuild/bazel#27296 ## Reliability improvements (8.5.0) - Cache invalidation: Source directory contents now tracked for proper invalidation bazelbuild/bazel#27417 - Configuration: Add ctx.configuration.short_id for identifying configurations bazelbuild/bazel#27128 - Git repositories: git_repository now checks out default branch when unspecified bazelbuild/bazel#27705 - Query: Add executables() function and fix genquery for external repos bazelbuild/bazel#27560 bazelbuild/bazel#27117 - Registry mirrors: --module_mirrors now supports per-registry mirror specification bazelbuild/bazel#27531 ## Bug fixes (8.5.1) - Remote cache: Add option to continue with local execution if remote cache is unavailable bazelbuild/bazel#27996 - Repository handling: Fix crash when mixing use_repo_rule and --inject_repository bazelbuild/bazel#27995 - Repository cache: Fix permission denied issue with --experimental_repository_cache_hardlinks bazelbuild/bazel#28161 - Local execution: Fix incorrect SkyframeLookupResult usage bazelbuild/bazel#27994 Both 8.5.0 and 8.5.1 are fully backward compatible with Bazel 8.0. ## Dependency updates - Upgrade rules_go from 0.57.0 to 0.59.0 for Bazel 8.5+ compatibility bazel-contrib/rules_go#4493 - Configure sh_configure extension for rules_shell to auto-detect shell toolchain ## Platform-specific changes - Windows: Configure hermetic shell via --repo_env=BAZEL_SH which is used by both sh_configure (sh_binary/sh_test) and --shell_executable (genrule/run_shell). This eliminates dependency on system environment variables. - Windows: Disable code coverage collection (--nocollect_code_coverage) to avoid shell toolchain issues. Coverage requires sh_binary (collect_coverage) which needs a hermetic shell toolchain not yet available. bazelbuild/rules_shell#4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This upgrade brings several performance improvements and bug fixes: #### Performance improvements - remote execution: bazelbuild/bazel#27564 - module extensions: bazelbuild/bazel#27296 #### Reliability improvements - cache invalidation: bazelbuild/bazel#27417 - configuration: bazelbuild/bazel#27128 - Git repositories: bazelbuild/bazel#27705 - query: - bazelbuild/bazel#27560 - bazelbuild/bazel#27117 - registry mirrors: bazelbuild/bazel#27531 #### Bug fixes - remote cache: bazelbuild/bazel#27996 - repository handling: bazelbuild/bazel#27995 - repository cache: bazelbuild/bazel#28161 - local execution: bazelbuild/bazel#27994
### What does this PR do? Bump `bazel` version from [8.4.2](https://github.com/bazelbuild/bazel/releases/tag/8.4.2) to [8.5.1](https://github.com/bazelbuild/bazel/releases/tag/8.5.1). To make that happen, we also need to: - specify which `bash` to use on Windows when evaluating **repository** rules, for compatibility with bazelbuild/bazel#26927: ``` ERROR: /path/to/external/bazel_tools/tools/test/BUILD:23:10: in sh_binary rule @@bazel_tools//tools/test:collect_coverage: Error in fail: No suitable shell toolchain found: * if you are running Bazel on Windows, set the BAZEL_SH environment variable to the path of bash.exe ``` (actual job output: https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1349246422#L77) - bump `rules_go` from (implicit) [0.57.0](https://github.com/bazel-contrib/rules_go/releases/tag/v0.57.0) to (explicit) [0.59.0](https://github.com/bazel-contrib/rules_go/releases/tag/v0.59.0) for bazel-contrib/rules_go/pull/4493 to be compatible with bazelbuild/bazel/pull/27296: ``` Error: 'Facts' value has no field or method 'clear' ``` ### Motivation 1. this upgrade alone brings several improvements and bug fixes, among which: - bazelbuild/bazel#27117 - bazelbuild/bazel#27296 - bazelbuild/bazel#27417, covers: - bazelbuild/bazel#25834 - bazelbuild/bazel#25863 - bazelbuild/bazel#25864 - bazelbuild/bazel#25870 - bazelbuild/bazel#26698 - bazelbuild/bazel#27531 - bazelbuild/bazel#27560 - bazelbuild/bazel#27564 - bazelbuild/bazel#27705 - bazelbuild/bazel#27995 - bazelbuild/bazel#27996 2. `bazel` 9.0 is due soon, so better off favoring incremental bumps. ### Additional Notes Leveraging [the latter](bazelbuild/bazel#27996) might allow us to later reconsider whether we'd like to go back to the `--remote_cache` flag (instead of the `--remote_executor` flag that we had to switch to in #44962). Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
The
git_repositoryandnew_git_repositoryrules currently require not only the remote repository URI to be specified but also either the branch, tag or revision (commit) to check out. This PR removes the latter requirement. If no branch, tag or revision are specified, the repo's default branch will be checked out.The main reason for introducing this proposed change, is because I noticed certain Bazel rules already generate
git_repositorytargets from git URIs or other git repo specs that might not have a branch, tag or revision specified. These rules then typically default to a branch name ofmaster, which is not correct in general. This change will allow those rules to simply omit the branch, tag and revision from the generatedgit_repositorytargets, to check out the repo's default branch.An alternative, more explicit, interface for specifying that the default branch is to be checked out, would have been to add an optional boolean
default_branchattribute to thegit_repositoryandnew_git_repositoryrules. The presence of that attribute would be mutually exclusive with the presence ofbranch,tagandcommit. Let me know if that interface is preferable.Addresses issue #27610.
Closes #27611.
PiperOrigin-RevId: 833710273
Change-Id: I7bc18efcbcfcaba61bf27052fecceb50336d2eb3
Commit ee3af97