mirror of
https://github.com/flutter/flutter.git
synced 2026-02-12 22:03:04 +08:00
It worked on the Mac version of Powershell (`pwsh`) but [not on the Windows bots](https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8709168939844960513/+/u/run_test.dart_for_framework_tests_shard_and_subshard_misc/stdout): ```txt 00:09 +37 ~2 -3: C:/b/s/w/ir/x/w/flutter/dev/tools/test/last_engine_commit_test.dart: returns the last engine commit [E] Failed running "powershell [C:\b\s\w\ir\x\t\last_engine_commit_test.88f44c9f\flutter\bin\internal\last_engine_commit.ps1]" (exit code = 1), stdout: stderr: Join-Path : A positional parameter cannot be found that accepts argument 'internal'. At C:\b\s\w\ir\x\t\last_engine_commit_test.88f44c9f\flutter\bin\internal\last_engine_commit.ps1:29 char:35 + ... SION_PATH = Join-Path $gitToplevel "bin" "internal" "release-candidat ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Join-Path], ParentContainsErrorRecordException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand ``` ... this looks safer, I'll make sure it passes pre-subs this time.
68 lines
2.8 KiB
PowerShell
68 lines
2.8 KiB
PowerShell
# Copyright 2014 The Flutter Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
# Based on the current repository state, writes on stdout the last commit in the
|
|
# git tree that edited either `DEPS` or any file in the `engine/` sub-folder,
|
|
# which is used to ensure `bin/internal/engine.version` is set correctly.
|
|
#
|
|
# ---------------------------------- NOTE ---------------------------------- #
|
|
#
|
|
# Please keep the logic in this file consistent with the logic in the
|
|
# `last_engine_commit.sh` script in the same directory to ensure that Flutter
|
|
# continues to work across all platforms!
|
|
#
|
|
# https://github.com/flutter/flutter/blob/main/docs/tool/Engine-artifacts.md.
|
|
#
|
|
# Want to test this script?
|
|
# $ cd dev/tools
|
|
# $ dart test test/last_engine_commit_test.dart
|
|
#
|
|
# -------------------------------------------------------------------------- #
|
|
|
|
$ErrorActionPreference = "Stop" # Equivalent to 'set -e' in bash
|
|
|
|
$progName = Split-Path -parent $MyInvocation.MyCommand.Definition
|
|
$flutterRoot = (Get-Item $progName).parent.parent.FullName
|
|
$gitToplevel = (git rev-parse --show-toplevel).Trim()
|
|
|
|
$Path1 = Join-Path $gitToplevel "bin"
|
|
$Path2 = Join-Path $Path1 "internal"
|
|
$RELEASE_CANDIDATE_VERSION_PATH = Join-Path $Path2 "release-candidate-branch.version"
|
|
|
|
# 1. Determine the reference commit: the last commit that changed
|
|
# 'bin/internal/release-candidate-branch.version'.
|
|
# This serves as the starting point for evaluating changes on the current branch.
|
|
$REFERENCE_COMMIT = ""
|
|
try {
|
|
$REFERENCE_COMMIT = (git log -1 --pretty=format:%H -- "$RELEASE_CANDIDATE_VERSION_PATH" -ErrorAction Stop).Trim()
|
|
}
|
|
catch {
|
|
# If git log fails (e.g., file not found or no history), $REFERENCE_COMMIT will remain empty.
|
|
}
|
|
|
|
# If we did not find this reference commit, fail.
|
|
if ([string]::IsNullOrEmpty($REFERENCE_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 "No file $RELEASE_CANDIDATE_VERSION_PATH found, or it has no history." -ErrorAction Stop
|
|
exit 1
|
|
}
|
|
|
|
# 2. Define the history range to search within: commits reachable from HEAD
|
|
# but not from the REFERENCE_COMMIT. This focuses the search on commits
|
|
# *unique to the current branch* since that file was last changed.
|
|
$HISTORY_RANGE = "$REFERENCE_COMMIT..HEAD"
|
|
$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 REFERENCE_COMMIT itself.
|
|
if ([string]::IsNullOrEmpty($ENGINE_COMMIT)) {
|
|
$ENGINE_COMMIT = $REFERENCE_COMMIT
|
|
}
|
|
|
|
Write-Output $ENGINE_COMMIT
|