From 4d9a7c4fffba1f1a9c8630f98e7632a01aa63e12 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Wed, 16 Sep 2020 16:34:52 +0200 Subject: [PATCH] Add updatescript --- THW | 2 +- update.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 update.sh diff --git a/THW b/THW index 93c8442..f8dcefa 160000 --- a/THW +++ b/THW @@ -1 +1 @@ -Subproject commit 93c8442f86eff27e1fede19cb32425191856a161 +Subproject commit f8dcefa2c4c71b4f7c3d172dab5c40f96d7612e1 diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..5d6fdd6 --- /dev/null +++ b/update.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +function look_for_update() { + 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" + git pull + 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 + fi +} + +export -f look_for_update +find . -maxdepth 1 -type d -exec bash -c 'look_for_update "$0"' {} \; + +if [ -z $1 ]; then + read -p "Press return" +fi \ No newline at end of file