From b0e5a7af11cd3c9c709784636151e87275bb0f28 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Sun, 5 May 2024 13:47:54 +0800 Subject: [PATCH] run submmodule update in the script --- tools/setup-vendor-flutter | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/setup-vendor-flutter b/tools/setup-vendor-flutter index 6f28cccb6d1..71a6ac57626 100755 --- a/tools/setup-vendor-flutter +++ b/tools/setup-vendor-flutter @@ -6,14 +6,25 @@ this_dir=${BASH_SOURCE[0]%/*} # shellcheck source=tools/lib/git.sh . "${this_dir}"/lib/git.sh +divider_line='================================================================' # One-time setup to let git submodule + flutter SDK know that we're # using the main channel (main branch). -# We should do a quick check that there's no changes. +# Otherwise, `flutter doctor` complains about being on a user branch. +# We do a quick check that there's no changes. if ! submodule_is_clean "vendor/flutter" ; then - echo >&2 "There are changes in the 'vendor/flutter' tree or it is not initialized." - echo >&2 "Please run 'git submodule update --init' then run this script again." - exit 1 + echo "Initializing 'vendor/flutter' submodule:" + echo "${divider_line}" + if ! git submodule update --init ; then + echo "${divider_line}" + echo >&2 "Failed to initialize the 'vendor/flutter' submodule, please resolve the issues indicated above then run this script again." + exit 1 + else + echo "${divider_line}" + fi +fi +# Check if current branch is main, if not, switch to main +if [[ $(git -C vendor/flutter branch --show-current) == "main" ]]; then + exit 0 fi - git -C vendor/flutter checkout -B main HEAD