diff --git a/bin/flutter.bat b/bin/flutter.bat index 36b96fd0f8..168c1537c3 100644 --- a/bin/flutter.bat +++ b/bin/flutter.bat @@ -15,6 +15,21 @@ SETLOCAL ENABLEDELAYEDEXPANSION FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi +REM If available, add location of bundled mingit to PATH +SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd +IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path% + +REM Test if Git is available on the Host +where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1 +REM Test if the flutter directory is a git clone, otherwise git rev-parse HEAD would fail +IF NOT EXIST "%flutter_root%\.git" ( + ECHO Error: The Flutter directory is not a clone of the GitHub project. + ECHO The flutter tool requires Git in order to operate properly; + ECHO to set up Flutter, run the following command: + ECHO git clone -b stable https://github.com/flutter/flutter.git + EXIT /B 1 +) + REM Include shared scripts in shared.bat SET shared_bin=%FLUTTER_ROOT%/bin/internal/shared.bat CALL "%shared_bin%" diff --git a/bin/internal/shared.bat b/bin/internal/shared.bat index cd95979065..efc7180dab 100644 --- a/bin/internal/shared.bat +++ b/bin/internal/shared.bat @@ -26,21 +26,6 @@ SET pub_cache_path=%FLUTTER_ROOT%\.pub-cache SET dart=%dart_sdk_path%\bin\dart.exe SET pub=%dart_sdk_path%\bin\pub.bat -REM If available, add location of bundled mingit to PATH -SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd -IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path% - -REM Test if Git is available on the Host -where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1 -REM Test if the flutter directory is a git clone, otherwise git rev-parse HEAD would fail -IF NOT EXIST "%flutter_root%\.git" ( - ECHO Error: The Flutter directory is not a clone of the GitHub project. - ECHO The flutter tool requires Git in order to operate properly; - ECHO to set up Flutter, run the following command: - ECHO git clone -b stable https://github.com/flutter/flutter.git - EXIT /B 1 -) - REM Detect which PowerShell executable is available on the Host REM PowerShell version <= 5: PowerShell.exe REM PowerShell version >= 6: pwsh.exe