Skip to content

Commit 01a0326

Browse files
committed
Upstream and Origin check
Fixes flutter#160558
1 parent d14259a commit 01a0326

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

bin/internal/update_dart_sdk.ps1

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ if ((Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot
2727
# Calculate the engine hash from tracked git files.
2828
$branch = (git -C "$flutterRoot" rev-parse --abbrev-ref HEAD)
2929
if ($null -eq $Env:LUCI_CONTEXT) {
30-
$engineVersion = (git -C "$flutterRoot" merge-base HEAD upstream/master)
30+
$ErrorActionPreference = "Continue"
31+
git -C "$flutterRoot" remote get-url upstream *> $null
32+
$exitCode = $?
33+
$ErrorActionPreference = "Stop"
34+
if ($exitCode) {
35+
$engineVersion = (git -C "$flutterRoot" merge-base HEAD upstream/master)
36+
} else {
37+
$engineVersion = (git -C "$flutterRoot" merge-base HEAD origin/master)
38+
}
3139
}
3240
else {
3341
$engineVersion = (git -C "$flutterRoot" rev-parse HEAD)

bin/internal/update_dart_sdk.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ if [ -f "$FLUTTER_ROOT/DEPS" ] && [ -f "$FLUTTER_ROOT/engine/src/.gn" ]; then
2727
BRANCH=$(git -C "$FLUTTER_ROOT" rev-parse --abbrev-ref HEAD)
2828
# In a fusion repository; the engine.version comes from the git hashes.
2929
if [ -z "${LUCI_CONTEXT}" ]; then
30-
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD upstream/master)
30+
set +e
31+
# Run the git command and capture the exit code
32+
git -C "$flutterRoot" remote get-url upstream > /dev/null 2>&1
33+
exit_code=$?
34+
set -e
35+
36+
if [[ $exit_code -eq 0 ]]; then
37+
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD upstream/master)
38+
else
39+
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" merge-base HEAD origin/master)
40+
fi
3141
else
3242
ENGINE_VERSION=$(git -C "$FLUTTER_ROOT" rev-parse HEAD)
3343
fi

0 commit comments

Comments
 (0)