From 19a803edf68fa97d97770a2d7f2d217cf3f724c6 Mon Sep 17 00:00:00 2001 From: suchAdemon Date: Wed, 26 Jan 2022 13:26:52 +0100 Subject: [PATCH] gitea_get_notifications.sh: fixed counts --- gitea_get_notifications.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gitea_get_notifications.sh b/gitea_get_notifications.sh index 825a6ba..d7b7c9c 100755 --- a/gitea_get_notifications.sh +++ b/gitea_get_notifications.sh @@ -42,12 +42,23 @@ fi for open_noti in ${open_notis}; do noti_id="$(grep -oE "^[0-9]+" <<<"${open_noti}")" 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 let open_count+=1 fi 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}\"}"