Bazel docs: Only generate unversioned redirects for the master tarball Note that this is not a perfect solution, since if a page is added or removed in master, then we will either generate an unversioned redirect that points to a 404 (not great but not a big deal either), or miss an unversioned redirect for a page that exists in the latest release (also not great, but also not a big deal since we probably removed that page for a reason?) RELNOTES: PiperOrigin-RevId: 314115260
diff --git a/site/jekyll-tree.sh b/site/jekyll-tree.sh index 9c1b8d9..905ae46 100755 --- a/site/jekyll-tree.sh +++ b/site/jekyll-tree.sh
@@ -151,19 +151,22 @@ # During setup, all documentation under docs are moved to the /versions/$VERSION # directory. This leaves nothing in the root directory. # -# This function generates a redirect from the root of the site for the given -# doc page under /versions/$LATEST_RELEASE_VERSION so that +# As a fix, when generating the master tarball, this function generates a +# redirect from the root of the site for the given doc page under +# /versions/$LATEST_RELEASE_VERSION so that # https://docs.bazel.build/foo.html will be redirected to # https://docs.bazel.build/versions/$LATEST_RELEASE_VERSION/foo.html function gen_redirects { - pushd "$VERSION_DIR" > /dev/null - for f in $(find . -name "*.html" -type f); do - gen_redirect $f - done - for f in $(find . -name "*.md" -type f); do - gen_redirect $f - done - popd > /dev/null + if [[ "$VERSION" == "master" ]]; then + pushd "$VERSION_DIR" > /dev/null + for f in $(find . -name "*.html" -type f); do + gen_redirect $f + done + for f in $(find . -name "*.md" -type f); do + gen_redirect $f + done + popd > /dev/null + fi } # Creates a tar archive containing the final Jekyll tree.