Upstream and Origin check (#160574)

Several use cases for `origin` as default:

* Some github actions checkout the tree
* Some users download from flutter.dev and then use `master`

Fixes #160558
This commit is contained in:
John McDole 2024-12-18 21:31:21 -08:00 committed by GitHub
parent d14259a25d
commit 0fcb6aa5bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View File

@ -27,7 +27,15 @@ if ((Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot
# Calculate the engine hash from tracked git files.
$branch = (git -C "$flutterRoot" rev-parse --abbrev-ref HEAD)
if ($null -eq $Env:LUCI_CONTEXT) {
$engineVersion = (git -C "$flutterRoot" merge-base HEAD upstream/master)
$ErrorActionPreference = "Continue"
git -C "$flutterRoot" remote get-url upstream *> $null
$exitCode = $?
$ErrorActionPreference = "Stop"
if ($exitCode) {
$engineVersion = (git -C "$flutterRoot" merge-base HEAD upstream/master)
} else {
$engineVersion = (git -C "$flutterRoot" merge-base HEAD origin/master)
}
}
else {
$engineVersion = (git -C "$flutterRoot" rev-parse HEAD)

View File

@ -27,7 +27,17 @@ if [ -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
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD upstream/master)
set +e
# Run the git command and capture the exit code
git -C "$FLUTTER_ROOT" remote get-url upstream > /dev/null 2>&1
exit_code=$?
set -e
if [[ $exit_code -eq 0 ]]; then
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD upstream/master)
else
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD origin/master)
fi
else
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" rev-parse HEAD)
fi