Skip to content

Commit b6cc066

Browse files
committed
add safety check before running checkout
1 parent 851cb0f commit b6cc066

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tools/lib/git.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,13 @@ git_base_commit() {
9090
git_changed_files() {
9191
git diff --name-only --diff-filter=d "$@"
9292
}
93+
94+
# Note that this assumes ONE submodule. If we ever have more than one,
95+
# we'll need to generalize this.
96+
submodule_is_clean()
97+
{
98+
# first character of every line status indicates the status of the
99+
# submodule. If there is a space, it means the submodule is clean
100+
# and initiated.
101+
git submodule status | grep -q "^ "
102+
}

tools/setup-vendor-flutter

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
this_dir=${BASH_SOURCE[0]%/*}
5+
6+
# shellcheck source=tools/lib/git.sh
7+
. "${this_dir}"/lib/git.sh
8+
9+
410
# One-time setup to let git submodule + flutter SDK know that we're
511
# using the main channel (main branch).
12+
# We should do a quick check that there's no changes.
13+
if ! submodule_is_clean; then
14+
echo >&2 "There are changes in the submodule or it is not initialized."
15+
echo >&2 "Please run 'git submodule update --init' then run this script again."
16+
exit 1
17+
fi
18+
619
git -C vendor/flutter checkout -B main HEAD

0 commit comments

Comments
 (0)