on master help sign in
Update create.sh to quickly check for and update missing submodules
962abceEthan P
assets/create.sh+34−2
@@ -2,10 +2,42 @@
2set -euo pipefail
2set -euo pipefail
3
3
4ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+REPO_DIR="$ASSET_DIR/.."
5
6
6# Ensure submodules are initialized.
7# Ensure submodules are initialized.
8+function update_submodules() {
9+ local submodule
10+ local submodule_prompt=unspecified
11+ local submodule_path
12+
13+ {
14+ while { read -r submodule && read -r submodule_path; } <&3; do
15+ if ! [[ -d "${REPO_DIR}/.git/modules/${submodule}" ]] && [[ -d "${REPO_DIR}/${submodule_path}" ]]; then
16+ if [[ "$submodule_prompt" = "unspecified" ]]; then
17+ echo "One or more submodules were found to be uninitialized."
18+ printf "Initialize and update them? [Y/n] "
19+ read -r submodule_prompt
20+ fi
21+
22+ case "$submodule_prompt" in
23+ y|yes|'') {
7−git submodule init
24+ git -C "$REPO_DIR" submodule update --init "$submodule_path"
8−git submodule update
25+ };;
26+ n|no) {
27+ return
28+ };;
29+ *) {
30+ echo "Unknown answer. Not updating submodules."
31+ };;
32+ esac
33+ fi
34+ done
35+ } 3< <(git config --file "${REPO_DIR}/.gitmodules" --null --get-regexp path | xargs -0 printf "%s\n" | sed 's/^submodule.//;s/.path$//')
36+}
37+
38+if [ -t 0 ]; then
39+ update_submodules
40+fi
9
41
10# Always remove the local cache to avoid any confusion
42# Always remove the local cache to avoid any confusion
11bat cache --clear
43bat cache --clear