From 60048821d6b6cbe900cd994d05f0b9a603571c0f 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 --- README.md | 1 - tools/setup-vendor-flutter | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 22ac9157d1..72d3435744 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,6 @@ Two specific points to expand on: 1.1. Initialize the pinned Flutter tree: ```sh - git submodule update --init tools/setup-vendor-flutter ``` diff --git a/tools/setup-vendor-flutter b/tools/setup-vendor-flutter index 6f28cccb6d..71a6ac5762 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