gitea_wait_for_pr.sh: adds script to waif for closed PRs in gitea

This commit is contained in:
Oliver Schraml 2022-08-23 14:30:49 +02:00 committed by suchademon
parent db9cdfc465
commit 278e52ef03
Signed by: oliver.schraml
GPG Key ID: A55864B79D0D0228
1 changed files with 37 additions and 0 deletions

37
gitea_wait_for_pr.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
sleep_time="${1:-30}"
if [ "${sleep_time}" == "count" ]; then
counter=$(ps afxj | grep -v grep | grep -E "bash .*gitea_wait_for_pr.sh$" | wc -l)
if [ $counter -gt 0 ]; then
i3status_state="Critical"
msg_counter="Watching: ${counter}"
else
i3status_state="Idle"
msg_counter="NoPRW"
fi
echo "{\"state\":\"${i3status_state}\", \"text\":\"${msg_counter}\"}"
exit 0
fi
pr_data=$(tea pr ls | grep -vE '^\+-----|^\| INDEX|^\| +\|' | column | sed -E 's/^\|//g;s/ *\| */|/g;s/\|\|/\|/g' | column -dt -s "\|" -o " " | rofi -dmenu -i -config ~/VersionControl/configs/ALL_config/.global_rofi.conf -matching regex)
pr_nr=$(awk '{print $1}' <<<"${pr_data}")
if ! grep -qE "^[0-9]+$" <<<"${pr_nr}" ; then
echo "pr_nr is not a number: ${pr_nr}"
exit 1
fi
while true; do
if tea pr ls | grep -qE "^\| *${pr_nr} *\|" ; then
echo "$(date +"%F %T") - PR still open (recheck in ${sleep_time})"
sleep $sleep_time
else
echo "$(date +"%F %T") - PR got closed"
notify-send -u critical -a PR_watcher -A "continue" "${pr_data}" "PR ${pr_nr} closed"
break
fi
done