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,26 +18,24 @@ colorize_changelog() {
-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'
for draft in $DRAFTS; do
IFS='|' parts=(${draft})
name=${parts[0]}
tag=${parts[1]}
title=${parts[2]}
for name in $(git submodule foreach --quiet 'basename $PWD'); do
pushd $name > /dev/null
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')"
if [ ! -z "$draft" ]; then
IFS=$'\n' parts=(${draft})
tag="${parts[0]}"
title="${parts[1]}"
url="${parts[2]}"
IFS=$'\n' description="${parts[*]:3}"
echo
echo -e "\e[1m$name\e[0m: $title"
echo -e "\e[1m$name\e[0m: $title\n \e[34m$url\e[0m"
pushd $name > /dev/null
description=$(hub release show $tag)
changes=$(echo $description | grep -Po '^\s*\K\*.*$' )
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)
@ -47,6 +45,7 @@ for draft in $DRAFTS; do
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
echo "$changes" | colorize_changelog
fi
popd > /dev/null
done