Skip to content

Commit 6a23700

Browse files
authored
Add tools/sync-bazelversion.sh, commit results (bazel-contrib#1629)
* Add tools/sync-bazelversion.sh, commit results Ensures Bazelisk uses the same Bazel version in every workspace in the project. Part of bazel-contrib#1482. I discovered that the workspaces under the main workspace were running the latest mainline Blaze release I had installed, instead of 6.5.0 from `.bazelversion`. Now all the workspaces are synchronized on the same Bazel version. As noted in the `tools/sync-bazelversion.sh` comments, symlinks or an `import ../.bazelversion` mechanism would be preferable. However, the former can surprise Windows users, and Bazelisk doesn't support the latter. * Move sync-bazelversion.sh from tools/ to scripts/ Requested by @simuons in bazel-contrib#1629.
1 parent 9bbdc8a commit 6a23700

File tree

13 files changed

+44
-1
lines changed

13 files changed

+44
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.3.1
1+
6.5.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

examples/crossbuild/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

examples/scala3/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

examples/semanticdb/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

scripts/sync-bazelversion.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Synchronizes .bazelversion in nested workspaces with the top level workspace.
4+
#
5+
# These could be symlinks, but that might break Windows users who don't know how
6+
# to enable symlinks. Of course, they're programmers, they should learn, but
7+
# avoiding surprises as a general principle is best.
8+
#
9+
# What would be ideal is the `import ../.bazelrc` syntax supported by Bazel, but
10+
# Bazelisk doesn't currently support that.
11+
12+
ROOTDIR="${BASH_SOURCE[0]%/*}/.."
13+
cd "$ROOTDIR"
14+
15+
if [[ "$?" -ne 0 ]]; then
16+
echo "Could not change to $ROOTDIR." >&2
17+
exit 1
18+
elif [[ ! -r .bazelversion ]]; then
19+
echo ".bazelversion doesn't exist or isn't readable in $PWD." >&2
20+
exit 1
21+
fi
22+
23+
while IFS="" read repo_marker_path; do
24+
repo_path="${repo_marker_path%/*}"
25+
26+
# We search for WORKSPACE and MODULE.bazel instead of .bazelversion in case
27+
# anyone adds new child repositories. But we need to guard against overwriting
28+
# the top-level WORKSPACE and MODULE.bazel files.
29+
if [[ "$repo_path" != "$repo_marker_path" ]]; then
30+
cp .bazelversion "$repo_path"
31+
fi
32+
done < <(find [A-Za-z0-9]* \( -name "WORKSPACE*" -or -name "MODULE.bazel" \))

test_cross_build/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

test_version/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

third_party/test/proto/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

0 commit comments

Comments
 (0)