mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-23 00:03:27 +01:00
Update create.sh to quickly check for and update missing submodules
This commit is contained in:
parent
95f2e5bbb7
commit
962abcef80
36
assets/create.sh
vendored
36
assets/create.sh
vendored
@ -2,10 +2,42 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
REPO_DIR="$ASSET_DIR/.."
|
||||||
|
|
||||||
# Ensure submodules are initialized.
|
# Ensure submodules are initialized.
|
||||||
git submodule init
|
function update_submodules() {
|
||||||
git submodule update
|
local submodule
|
||||||
|
local submodule_prompt=unspecified
|
||||||
|
local submodule_path
|
||||||
|
|
||||||
|
{
|
||||||
|
while { read -r submodule && read -r submodule_path; } <&3; do
|
||||||
|
if ! [[ -d "${REPO_DIR}/.git/modules/${submodule}" ]] && [[ -d "${REPO_DIR}/${submodule_path}" ]]; then
|
||||||
|
if [[ "$submodule_prompt" = "unspecified" ]]; then
|
||||||
|
echo "One or more submodules were found to be uninitialized."
|
||||||
|
printf "Initialize and update them? [Y/n] "
|
||||||
|
read -r submodule_prompt
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$submodule_prompt" in
|
||||||
|
y|yes|'') {
|
||||||
|
git -C "$REPO_DIR" submodule update --init "$submodule_path"
|
||||||
|
};;
|
||||||
|
n|no) {
|
||||||
|
return
|
||||||
|
};;
|
||||||
|
*) {
|
||||||
|
echo "Unknown answer. Not updating submodules."
|
||||||
|
};;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
} 3< <(git config --file "${REPO_DIR}/.gitmodules" --null --get-regexp path | xargs -0 printf "%s\n" | sed 's/^submodule.//;s/.path$//')
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -t 0 ]; then
|
||||||
|
update_submodules
|
||||||
|
fi
|
||||||
|
|
||||||
# Always remove the local cache to avoid any confusion
|
# Always remove the local cache to avoid any confusion
|
||||||
bat cache --clear
|
bat cache --clear
|
||||||
|
Loading…
Reference in New Issue
Block a user