File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,7 +330,36 @@ function build {
330330 )
331331}
332332
333+ function check_submodule_sync {
334+ # Check if submodules match the commits tracked by the main repo
335+ local out_of_sync=()
336+ while IFS= read -r line; do
337+ # git submodule status prefixes with '-' (not init), '+' (wrong commit), or ' ' (ok)
338+ if [[ " $line " == +* ]]; then
339+ # Extract submodule path (second field)
340+ local path
341+ path=$( echo " $line " | awk ' {print $2}' )
342+ out_of_sync+=(" $path " )
343+ fi
344+ done < <( git submodule status --recursive)
345+
346+ if [[ ${# out_of_sync[@]} -gt 0 ]]; then
347+ warning " The following submodules do not match the commits tracked by the repository:"
348+ for sm in " ${out_of_sync[@]} " ; do
349+ warning " - $sm "
350+ done
351+ read -r -p " $( txt bold) $( txt yellow) [?] Update submodules to match? [Y/n] $( txt reset) " answer
352+ if [[ -z " $answer " || " $answer " =~ ^[Yy] ]]; then
353+ info " => Updating submodules"
354+ git submodule update --init --recursive
355+ else
356+ warning " Continuing with mismatched submodules."
357+ fi
358+ fi
359+ }
360+
333361function up {
362+ check_submodule_sync
334363 export REAL_HOSTNAME=" $( hostname) "
335364 export DEBUG=false
336365 export DISABLE_RESPONSE_CACHING=false
You can’t perform that action at this time.
0 commit comments