Utils/update.sh

39 lines
838 B
Bash
Raw Permalink Normal View History

2020-06-15 16:52:31 +02:00
#!/bin/bash
2019-03-29 17:43:02 +01:00
function look_for_update() {
2020-06-15 16:52:31 +02:00
if [[ $1 == ./.git ]] || [[ $1 == "." ]]; then
echo "Ignore $1"
return
fi
WithoutPrefix=$(echo -n $1 | cut -c 2-)
if grep -qx "$WithoutPrefix" .gitignore; then
echo "Ignore $1, because it's in .gitignore"
return
fi
printf -v FolderNameEscaped '%q' "$1"
if [[ -f $1/update.sh ]]; then
echo "Switch to subdir $1 and run update.sh"
cd "$1"
2020-09-16 16:24:38 +02:00
git pull
2020-06-15 16:52:31 +02:00
bash -c "./update.sh nobreak"
else
if [[ -f $1/.git ]]
then
echo "Pull $1"
cd "$1"
git pull
else
echo "Checkout master for $1"
git submodule update --init -- "$1"
cd "$1"
git checkout master
fi
2019-03-29 17:43:02 +01:00
fi
}
export -f look_for_update
find . -maxdepth 1 -type d -exec bash -c 'look_for_update "$0"' {} \;
2020-06-15 16:52:31 +02:00
if [ -z $1 ]; then
read -p "Press return"
fi