Add auto_get_git_submodule()

This commit is contained in:
clsty
2025-10-29 08:15:47 +08:00
parent 7982f43a62
commit 4672138b00
2 changed files with 24 additions and 0 deletions
+22
View File
@@ -287,3 +287,25 @@ function check_disk_space() {
return 0
}
function auto_get_git_submodule(){
local git_submodules_list=()
while IFS= read -r path; do
[ -z "$path" ] && continue
git_submodules_list+=("$path")
done < <(git submodule status --recursive 2>/dev/null | awk '{print $2}')
local missing=0
for p in "${git_submodules_list[@]}"; do
if [ ! -d "$p" ] || [ -z "$(ls -A "$p" 2>/dev/null)" ]; then
missing=1
break
fi
done
if [ "$missing" -eq 1 ]; then
x git submodule update --init --recursive
fi
}
+2
View File
@@ -81,6 +81,8 @@ function auto_backup_configs(){
}
#####################################################################################
showfun auto_get_git_submodule
v auto_get_git_submodule
# In case some dirs does not exists
v mkdir -p $XDG_BIN_HOME $XDG_CACHE_HOME $XDG_CONFIG_HOME $XDG_DATA_HOME