Skip to content

Commit

Permalink
Add tools/sync-bazelversion.sh, commit results
Browse files Browse the repository at this point in the history
Part of bazelbuild#1482.

Ensures Bazelisk uses the same Bazel version in every workspace in the
project.

I discovered that the workspaces under the main workspace were running
the latest mainline Blaze release I had installed. 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.
  • Loading branch information
mbland committed Oct 20, 2024
1 parent b19f5a1 commit 9a1f2f6
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dt_patches/test_dt_patches/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.1
6.5.0
1 change: 1 addition & 0 deletions dt_patches/test_dt_patches_user_srcjar/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions examples/crossbuild/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions examples/scala3/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions examples/semanticdb/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions examples/testing/multi_frameworks_toolchain/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions examples/testing/scalatest_repositories/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions examples/testing/specs2_junit_repositories/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions test_cross_build/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions test_version/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions third_party/test/example_external_workspace/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
1 change: 1 addition & 0 deletions third_party/test/proto/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.5.0
25 changes: 25 additions & 0 deletions tools/sync-bazelversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
#
# Synchronizes .bazelversion in nested workspaces with the top level workspace.
#
# These could be symlinks, but that might break Windows users who don't know how
# to enable symlinks. Of course, they're programmers, they should learn, but
# avoiding surprises as a general principle is best.
#
# What would be ideal is the `import ../.bazelrc` syntax supported by Bazel, but
# Bazelisk doesn't currently support that.

ROOTDIR="${BASH_SOURCE[0]%/*}/.."
cd "$ROOTDIR"

if [[ "$?" -ne 0 ]]; then
echo "Could not change to $ROOTDIR." >&2
exit 1
elif [[ ! -r .bazelversion ]]; then
echo ".bazelversion doesn't exist or isn't readable in $PWD." >&2
exit 1
fi

while IFS="" read rcpath; do
cp .bazelversion "${rcpath%/*}"
done < <(find [a-z]* -name '.bazelrc')

0 comments on commit 9a1f2f6

Please sign in to comment.