From 0e3ca084c4b50b80d609fe769e850d99c6e628ef Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 20 Aug 2024 15:31:05 +0200 Subject: [PATCH] fix(build): Allow update-apps.sh script to work with non-master branches Signed-off-by: provokateurin --- build/update-apps.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/build/update-apps.sh b/build/update-apps.sh index 444fd84c73e..c4de9410237 100755 --- a/build/update-apps.sh +++ b/build/update-apps.sh @@ -10,9 +10,23 @@ # It automatically: # - goes through all apps which are not shipped via server # - shows the app name in bold and uses whitespace for separation -# - changes to master and pulls quietly +# - changes to master/main and pulls quietly # - shows the 3 most recent commits for context -# - removes branches merged into master +# - removes branches merged into master/main # - … could even do the build steps if they are consistent for the apps (like `make`) -find apps* -maxdepth 2 -name .git -exec sh -c 'cd {}/../ && printf "\n\033[1m${PWD##*/}\033[0m\n" && git checkout master && git pull --quiet -p && git --no-pager log -3 --pretty=format:"%h %Cblue%ar%x09%an %Creset%s" && printf "\n" && git branch --merged master | grep -v "master$" | xargs git branch -d && cd ..' \; +set -euo pipefail + +for path in apps*/*/.git; do + ( + path="$(dirname "$path")" + cd "$path" + printf "\n\033[1m${PWD##*/}\033[0m\n" + branch="$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')" + git checkout "$branch" + git pull --quiet -p + git --no-pager log -3 --pretty=format:"%h %Cblue%ar%x09%an %Creset%s" + printf "\n" + git branch --merged "$branch" | grep -v "$branch$" | xargs git branch -d || true + ) +done -- 2.39.5