gitea_wait_for_pr.sh: added opts + better closed message
This commit is contained in:
parent
278e52ef03
commit
a50de39343
|
@ -1,7 +1,37 @@
|
|||
#!/bin/bash
|
||||
sleep_time="${1:-30}"
|
||||
sleep_time=30
|
||||
skip_wait=" -A \"continue\""
|
||||
count_only=false
|
||||
|
||||
if [ "${sleep_time}" == "count" ]; then
|
||||
usage() {
|
||||
echo "#####################################################################"
|
||||
echo "# Usage:"
|
||||
echo "#--------------------------------------------------------------------"
|
||||
echo "#"
|
||||
echo "# -c - counts all running wait scripts (output is json)"
|
||||
echo "# -s - skips the waiting of notifiaction confirmation"
|
||||
echo "# -t <seconds> - sets sleep time between rechecks (default: ${sleep_time})"
|
||||
echo "#"
|
||||
echo "# -h/? - displays this help message"
|
||||
echo "#"
|
||||
echo "#####################################################################"
|
||||
exit 64
|
||||
}
|
||||
|
||||
optstring="t:sc?h"
|
||||
|
||||
while getopts ${optstring} c; do
|
||||
case ${c} in
|
||||
c) count_only=true ;;
|
||||
s) skip_wait="" ;;
|
||||
t) sleep_time=${OPTARG} ;;
|
||||
*) usage ;;
|
||||
[h\?]) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if $count_only ; then
|
||||
counter=$(ps afxj | grep -v grep | grep -E "bash .*gitea_wait_for_pr.sh$" | wc -l)
|
||||
|
||||
if [ $counter -gt 0 ]; then
|
||||
|
@ -19,6 +49,7 @@ 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}")
|
||||
pr_msg="$(sed -E 's/^ +[0-9]+ +//g;s/ .*//g' <<<"${pr_data}")"
|
||||
|
||||
if ! grep -qE "^[0-9]+$" <<<"${pr_nr}" ; then
|
||||
echo "pr_nr is not a number: ${pr_nr}"
|
||||
|
@ -31,7 +62,7 @@ while true; do
|
|||
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"
|
||||
notify-send -u critical -a PR_watcher${skip_wait} "${pr_data}" "Closed: [$(basename "$(git rev-parse --show-toplevel)")/${pr_nr}] ${pr_msg}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue