gitea_get_notifications.sh: fixed counts

This commit is contained in:
Oliver Schraml 2022-01-26 13:26:52 +01:00 committed by suchademon
parent d092346c1f
commit 19a803edf6
Signed by: oliver.schraml
GPG Key ID: A55864B79D0D0228
1 changed files with 14 additions and 3 deletions

View File

@ -42,12 +42,23 @@ fi
for open_noti in ${open_notis}; do for open_noti in ${open_notis}; do
noti_id="$(grep -oE "^[0-9]+" <<<"${open_noti}")" noti_id="$(grep -oE "^[0-9]+" <<<"${open_noti}")"
noti_pr_id="$(grep -oE '@@#[0-9]+@@' <<<"${open_noti}" | sed -e 's/[@#]//g')" noti_pr_id="$(grep -oE '@@#[0-9]+@@' <<<"${open_noti}" | sed -e 's/[@#]//g')"
noti_repo="$(grep -oE '@[a-z0-9]+/[a-z0-9]+$' <<<"${open_noti}" | sed -e 's/@//g')" noti_repo="$(grep -oE '@[a-z0-9_-]+.[a-z0-9_-]+$' <<<"${open_noti}" | sed -e 's/@//g')"
pr_info=$(tea pr ls --state all --repo "${noti_repo}" | grep -E "^\| +${noti_pr_id} .* closed ") pr_info=$(tea pr ls --state all --repo "${noti_repo}" | grep -E "^\| +${noti_pr_id} .* open ")
if grep -qE " open +\| +${myuser} +\|" <<<"${pr_info}"; then if grep -qE " open +\| +${myuser} +\|" <<<"${pr_info}"; then
let open_count+=1 let open_count+=1
fi fi
done done
echo "GT: ${open_notis_count}/${open_count}/${merge_count}" i3status_state="Idle"
if [ $merge_count -gt 0 ]; then
i3status_state="Critical"
elif [ $open_count -gt 0 ]; then
open_notis_count=$((open_notis_count - open_count))
i3status_state="Warning"
elif [ $open_notis_count -gt 0 ]; then
i3status_state="Info"
fi
echo "{\"state\":\"${i3status_state}\", \"text\":\"GT: ${open_notis_count}/${open_count}/${merge_count}\"}"