Skip to content

Commit

Permalink
Allow native.bazel_version to be overridden for dev builds
Browse files Browse the repository at this point in the history
This is necessary to allow for accurate bisects of Bazel issues when rules rely on `bazel_features` for feature detection. The variable can be used to force the lowest version relevant to the bisect or, in the future, `bazelisk --bisect` could extrapolate the release version from tags.
  • Loading branch information
fmeum committed Dec 13, 2024
1 parent 1d4f849 commit 1dd6ed9
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class BlazeVersionInfo {
/** Key for the release timestamp is seconds. */
public static final String BUILD_TIMESTAMP = "Build timestamp as int";

// If the current version is a development version, this environment variable can be used to
// override the version string (e.g. to deal with version-based feature detection during a
// bisect).
public static final String BAZEL_DEV_VERSION_OVERRIDE_ENV_VAR = "BAZEL_DEV_VERSION_OVERRIDE";

private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

private static BlazeVersionInfo instance = null;
Expand Down Expand Up @@ -126,7 +131,14 @@ public String getReleaseName() {
*/
public String getVersion() {
String buildLabel = buildData.get(BUILD_LABEL);
return buildLabel != null ? buildLabel : "";
if (buildLabel != null) {
return buildLabel;
}
String override = System.getenv(BAZEL_DEV_VERSION_OVERRIDE_ENV_VAR);
if (override != null) {
return override;
}
return "";
}

/**
Expand Down

0 comments on commit 1dd6ed9

Please sign in to comment.