-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Allow a release without engine cherrypicks (adds fallback logic) #172184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,48 @@ $ErrorActionPreference = "Stop" | |
|
||
$progName = Split-Path -parent $MyInvocation.MyCommand.Definition | ||
$flutterRoot = (Get-Item $progName).parent.parent.FullName | ||
$gitToplevel = (git rev-parse --show-toplevel).Trim() | ||
# 1. Determine when we diverged from master. | ||
$MERGE_BASE_COMMIT = "" | ||
try { | ||
$MERGE_BASE_COMMIT = (git merge-base HEAD master).Trim() | ||
} | ||
catch { | ||
# If git merge-base fails (e.g., master not found, no common history), | ||
# $MERGE_BASE_COMMIT will remain empty. | ||
} | ||
|
||
cmd /c "git log -1 --pretty=format:%H -- ""$(git rev-parse --show-toplevel)/DEPS"" ""$(git rev-parse --show-toplevel)/engine""" | ||
# If we did not find a merge-base, fail | ||
if ([string]::IsNullOrEmpty($MERGE_BASE_COMMIT)) { | ||
Write-Error "Error: Could not determine a suitable engine commit." -ErrorAction Stop | ||
Write-Error "Current branch: $(git rev-parse --abbrev-ref HEAD).Trim()" -ErrorAction Stop | ||
Write-Error "Expected a different branch, from 'master', or a 'master' branch that exists and has history." -ErrorAction Stop | ||
exit 1 | ||
} | ||
|
||
# 2. Define and search history range to search within (unique to changes on this branch). | ||
$HISTORY_RANGE = "$MERGE_BASE_COMMIT..HEAD" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on a release branch, the content hash will also use the release version file in internal. Not sure if you need that here or not. I guess that would be handled in the fallback on line 54. |
||
$DEPS_PATH = Join-Path $gitToplevel "DEPS" | ||
$ENGINE_PATH = Join-Path $gitToplevel "engine" | ||
|
||
$ENGINE_COMMIT = (git log -1 --pretty=format:%H --ancestry-path $HISTORY_RANGE -- "$DEPS_PATH" "$ENGINE_PATH") | ||
|
||
# 3. If no engine-related commit was found within the current branch's history, fallback to the first commit on this branch. | ||
if ([string]::IsNullOrEmpty($ENGINE_COMMIT)) { | ||
# Find the oldest commit on HEAD that is *not* reachable from MERGE_BASE_COMMIT. | ||
# This is the first commit *on this branch* after it diverged from 'master'. | ||
$ENGINE_COMMIT = (git log --pretty=format:%H --reverse --ancestry-path "$MERGE_BASE_COMMIT..HEAD" | Select-Object -First 1).Trim() | ||
|
||
# Final check: If even this fallback fails (which would be highly unusual if MERGE_BASE_COMMIT was found), | ||
# then something is truly wrong. | ||
if ([string]::IsNullOrEmpty($ENGINE_COMMIT)) { | ||
Write-Error "Error: Unexpected state. MERGE_BASE_COMMIT was found ($MERGE_BASE_COMMIT), but no commits found on current branch after it." -ErrorAction Stop | ||
Write-Error "Current branch: $((git rev-parse --abbrev-ref HEAD).Trim())" -ErrorAction Stop | ||
Write-Error "History range searched for fallback: $HISTORY_RANGE" -ErrorAction Stop | ||
Write-Error "All commits on current branch (for debug):" -ErrorAction Stop | ||
(git log --pretty=format:%H) | Write-Error -ErrorAction Stop | ||
exit 1 | ||
} | ||
} | ||
|
||
Write-Output $ENGINE_COMMIT |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,37 @@ set -e | |
|
||
FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")" | ||
|
||
git log -1 --pretty=format:%H -- "$(git rev-parse --show-toplevel)/DEPS" "$(git rev-parse --show-toplevel)/engine" | ||
# 1. Determine when we diverged from master, and prevent set -e from exiting. | ||
MERGE_BASE_COMMIT="$(git merge-base HEAD master || echo "")" | ||
|
||
# If we did not find a merge-base, fail | ||
if [[ -z "$MERGE_BASE_COMMIT" ]]; then | ||
echo >&2 "Error: Could not determine a suitable engine commit." | ||
echo >&2 "Current branch: $(git rev-parse --abbrev-ref HEAD)" | ||
echo >&2 "Expected a different branch, from master" | ||
exit 1 | ||
fi | ||
|
||
# 2. Define and search history range to searhc within (unique to changes on this branch). | ||
HISTORY_RANGE="$MERGE_BASE_COMMIT..HEAD" | ||
ENGINE_COMMIT="$(git log -1 --pretty=format:%H --ancestry-path "$HISTORY_RANGE" -- "$(git rev-parse --show-toplevel)/DEPS" "$(git rev-parse --show-toplevel)/engine")" | ||
|
||
# 3. If no engine-related commit was found within the current branch's history, fallback to the first commit on this branch. | ||
if [[ -z "$ENGINE_COMMIT" ]]; then | ||
# Find the oldest commit on HEAD that is *not* reachable from MERGE_BASE_COMMIT. | ||
# This is the first commit *on this branch* after it diverged from 'master'. | ||
ENGINE_COMMIT="$(git log --pretty=format:%H --reverse --ancestry-path "$MERGE_BASE_COMMIT"..HEAD | head -n 1)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-blocking; you can use "git log -1" instead of "| head -n 1" or |
||
|
||
# Final check: If even this fallback fails (which would be highly unusual if MERGE_BASE_COMMIT was found), | ||
# then something is truly wrong. | ||
if [[ -z "$ENGINE_COMMIT" ]]; then | ||
echo >&2 "Error: Unexpected state. MERGE_BASE_COMMIT was found ($MERGE_BASE_COMMIT), but no commits found on current branch after it." | ||
echo >&2 "Current branch: $(git rev-parse --abbrev-ref HEAD)" | ||
echo >&2 "History range searched for fallback: $HISTORY_RANGE" | ||
echo >&2 "All commits on current branch (for debug):" | ||
git log --pretty=format:%H | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "$ENGINE_COMMIT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: This assumes this will only ever be run inside the flutter/**/ path. If someone runs ~/fluter/bin/internal/... from another git repo.. spicy.