Commit b75823d
[9.0.0] Support checking out the repo's default branch in
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 #27610.
Closes #27611.
PiperOrigin-RevId: 833710273
Change-Id: I7bc18efcbcfcaba61bf27052fecceb50336d2eb3
Commit
ee3af97
Co-authored-by: Pieter Agten <pieter.agten@gmail.com>git_repository/new_git_repository rule (#27701)1 parent 6909a69 commit b75823d
File tree
4 files changed
+66
-43
lines changed- src/test
- java/com/google/devtools/build/lib/blackbox/tests/workspace
- shell/bazel
- tools/build_defs/repo
4 files changed
+66
-43
lines changedLines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
155 | 188 | | |
156 | 189 | | |
157 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
| |||
189 | 193 | | |
190 | 194 | | |
191 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
192 | 200 | | |
193 | 201 | | |
194 | 202 | | |
| |||
203 | 211 | | |
204 | 212 | | |
205 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
206 | 217 | | |
207 | 218 | | |
208 | 219 | | |
| |||
217 | 228 | | |
218 | 229 | | |
219 | 230 | | |
| 231 | + | |
220 | 232 | | |
| 233 | + | |
221 | 234 | | |
222 | 235 | | |
223 | 236 | | |
224 | | - | |
| 237 | + | |
225 | 238 | | |
226 | 239 | | |
227 | 240 | | |
228 | 241 | | |
229 | 242 | | |
230 | | - | |
| 243 | + | |
231 | 244 | | |
232 | 245 | | |
233 | 246 | | |
| |||
249 | 262 | | |
250 | 263 | | |
251 | 264 | | |
252 | | - | |
| 265 | + | |
253 | 266 | | |
254 | 267 | | |
255 | 268 | | |
| |||
626 | 639 | | |
627 | 640 | | |
628 | 641 | | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
| 642 | + | |
656 | 643 | | |
657 | 644 | | |
658 | 645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
| 36 | + | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| |||
225 | 224 | | |
226 | 225 | | |
227 | 226 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
0 commit comments