Check for tracked engine.version before overriding (#163672)
Checking out a flutter release tag (e.g. `3.29.0`) will see the checked in engine.version file overridden. Don't do that. See: #163308
This commit is contained in:
@@ -19,6 +19,12 @@ $ErrorActionPreference = "Stop"
|
||||
$progName = Split-Path -parent $MyInvocation.MyCommand.Definition
|
||||
$flutterRoot = (Get-Item $progName).parent.parent.FullName
|
||||
|
||||
# On stable, beta, and release tags, the engine.version is tracked by git - do not override it.
|
||||
$trackedEngine = (git -C "$flutterRoot" ls-files bin/internal/engine.version) | Out-String
|
||||
if ($trackedEngine.length -ne 0) {
|
||||
return
|
||||
}
|
||||
|
||||
# Allow overriding the intended engine version via FLUTTER_PREBUILT_ENGINE_VERSION.
|
||||
#
|
||||
# This is for systems, such as Github Actions, where we know ahead of time the
|
||||
@@ -35,8 +41,6 @@ if (![string]::IsNullOrEmpty($env:FLUTTER_PREBUILT_ENGINE_VERSION)) {
|
||||
|
||||
# Test for fusion repository
|
||||
if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot\engine\src\.gn" -PathType Leaf)) {
|
||||
# Calculate the engine hash from tracked git files.
|
||||
$branch = (git -C "$flutterRoot" rev-parse --abbrev-ref HEAD)
|
||||
if ($null -eq $Env:LUCI_CONTEXT) {
|
||||
$ErrorActionPreference = "Continue"
|
||||
git -C "$flutterRoot" remote get-url upstream *> $null
|
||||
@@ -53,13 +57,11 @@ if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot\DEPS"
|
||||
}
|
||||
}
|
||||
|
||||
if (($branch -ne "stable" -and $branch -ne "beta")) {
|
||||
# Write the engine version out so downstream tools know what to look for.
|
||||
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
|
||||
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.version", $engineVersion, $utf8NoBom)
|
||||
# Write the engine version out so downstream tools know what to look for.
|
||||
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
|
||||
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.version", $engineVersion, $utf8NoBom)
|
||||
|
||||
# The realm on CI is passed in.
|
||||
if ($Env:FLUTTER_REALM) {
|
||||
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
|
||||
}
|
||||
# The realm on CI is passed in.
|
||||
if ($Env:FLUTTER_REALM) {
|
||||
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
|
||||
}
|
||||
|
||||
@@ -33,9 +33,14 @@ fi
|
||||
|
||||
FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
|
||||
|
||||
# On stable, beta, and release tags, the engine.version is tracked by git - do not override it.
|
||||
TRACKED_ENGINE="$(git -C "$FLUTTER_ROOT" ls-files bin/internal/engine.version)"
|
||||
if [[ -n "$TRACKED_ENGINE" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Test for fusion repository and no environment variable override.
|
||||
if [ -z "$ENGINE_VERSION" ] && [ -f "$FLUTTER_ROOT/DEPS" ] && [ -f "$FLUTTER_ROOT/engine/src/.gn" ]; then
|
||||
BRANCH=$(git -C "$FLUTTER_ROOT" rev-parse --abbrev-ref HEAD)
|
||||
# In a fusion repository; the engine.version comes from the git hashes.
|
||||
if [ -z "${LUCI_CONTEXT}" ]; then
|
||||
set +e
|
||||
@@ -54,12 +59,10 @@ if [ -z "$ENGINE_VERSION" ] && [ -f "$FLUTTER_ROOT/DEPS" ] && [ -f "$FLUTTER_ROO
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$BRANCH" != "stable" && "$BRANCH" != "beta" ]]; then
|
||||
# Write the engine version out so downstream tools know what to look for.
|
||||
echo $ENGINE_VERSION > "$FLUTTER_ROOT/bin/internal/engine.version"
|
||||
# Write the engine version out so downstream tools know what to look for.
|
||||
echo $ENGINE_VERSION > "$FLUTTER_ROOT/bin/internal/engine.version"
|
||||
|
||||
# The realm on CI is passed in.
|
||||
if [ -n "${FLUTTER_REALM}" ]; then
|
||||
echo $FLUTTER_REALM > "$FLUTTER_ROOT/bin/internal/engine.realm"
|
||||
fi
|
||||
# The realm on CI is passed in.
|
||||
if [ -n "${FLUTTER_REALM}" ]; then
|
||||
echo $FLUTTER_REALM > "$FLUTTER_ROOT/bin/internal/engine.realm"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user