show_drafts: only run hub once per submodule

This commit is contained in:
Odd Stråbø 2021-04-13 05:56:11 +02:00
parent cd67484eb1
commit 6112277189

View File

@ -18,35 +18,34 @@ colorize_changelog() {
-e "s/@([^ ]+)$/${esc}[1;30m@${esc}[0;36m\1${esc}[0m/gi" -e "s/@([^ ]+)$/${esc}[1;30m@${esc}[0;36m\1${esc}[0m/gi"
} }
echo "Fetching git release info..."
DRAFTS=$(
git submodule foreach \
'hub release --include-drafts -f "$(basename $PWD)|%T|%t|%S%n"' \
| grep draft
)
IFS=$'\n' IFS=$'\n'
for draft in $DRAFTS; do for name in $(git submodule foreach --quiet 'basename $PWD'); do
IFS='|' parts=(${draft})
name=${parts[0]}
tag=${parts[1]}
title=${parts[2]}
echo
echo -e "\e[1m$name\e[0m: $title"
pushd $name > /dev/null pushd $name > /dev/null
description=$(hub release show $tag) draft="$(hub release --include-drafts -L2 -f 'SOF:%S%n%T%n%t%n%U%n%b%nEOF%n' --color=always | sed -n -e '/SOF:draft/,/EOF/p' | sed -e '1d' -e '$d')"
changes=$(echo $description | grep -Po '^\s*\K\*.*$' )
meta_version=$(grep -Po "version: ?[\"']?\K.*(?=[\"']$)" build.yaml | rstrip_ver) if [ ! -z "$draft" ]; then
draft_version=$(echo $tag | grep -Po 'v\K.*' | rstrip_ver) IFS=$'\n' parts=(${draft})
if [ "$meta_version" != "$draft_version" ]; then tag="${parts[0]}"
echo -e " \e[1;31mVersion bump needed!" title="${parts[1]}"
echo -e " \e[0;31mDraft is for v\e[0m\e[1m$draft_version\e[0;31m, but build.yaml specifies v\e[0m\e[1m$meta_version\e[0m" url="${parts[2]}"
IFS=$'\n' description="${parts[*]:3}"
echo
echo -e "\e[1m$name\e[0m: $title\n \e[34m$url\e[0m"
changes=$(echo "$description" | grep -Po '^\s*\K\*.*$' )
meta_version=$(grep -Po "version: ?[\"']?\K.*(?=[\"']$)" build.yaml | rstrip_ver)
draft_version=$(echo $tag | grep -Po 'v\K.*' | rstrip_ver)
if [ "$meta_version" != "$draft_version" ]; then
echo -e " \e[1;31mVersion bump needed!"
echo -e " \e[0;31mDraft is for v\e[0m\e[1m$draft_version\e[0;31m, but build.yaml specifies v\e[0m\e[1m$meta_version\e[0m"
fi
echo "$changes" | colorize_changelog
fi fi
echo $changes | colorize_changelog
popd > /dev/null popd > /dev/null
done done