summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-01-03 17:19:27 +0100
committerErich Eckner <git@eckner.net>2018-01-03 17:19:27 +0100
commitee2b68656f6f0bdf154dc65934e59dbc0eb411eb (patch)
tree6ed5423c8bedaaba7632da0e38a33ba6a6908b57
parent73977f79b43cde3162e36c175df627c1f228dc51 (diff)
downloadbuilder-ee2b68656f6f0bdf154dc65934e59dbc0eb411eb.tar.xz
bin/ii-connect: watch and answer irc why-dont-you questions (in a loop)
-rwxr-xr-xbin/ii-connect49
1 files changed, 49 insertions, 0 deletions
diff --git a/bin/ii-connect b/bin/ii-connect
index 5c38367..e2b200c 100755
--- a/bin/ii-connect
+++ b/bin/ii-connect
@@ -29,3 +29,52 @@ if ! grep ' buildmaster\.archlinux32\.org .* buildmaster$' "${irc_dir}/out" | \
} > \
"${irc_dir}/in"
fi
+
+# start watch daemon if not running yet
+if ! pgrep -xf 'SCREEN -d -m ii-connect watch' > /dev/null; then
+ screen -d -m ii-connect watch
+fi
+
+# watch if asked to
+if [ "$1" = 'watch' ]; then
+ while pgrep -x 'ii' > /dev/null; do
+ find "${irc_dir}" \
+ -regextype sed \
+ -type f \
+ -name 'out' \
+ -printf '%p\n' | \
+ while read -r out_file; do
+ channel="${out_file%/out}"
+ channel="${channel##*/}"
+ if [ -z "${channel%%#*}" ]; then
+ prefix='buildmaster: '
+ else
+ prefix=''
+ fi
+ regex='^\S\+ \S\+ <\S\+> '"${prefix}"'why[- ]dont[- ]you \(build\|stabilize\|unstage\|keep\|stubbornly_keep\) '
+ if grep -q "${regex}" "${out_file}"; then
+ sed -n '
+ s/'"${regex}"'/\1 /
+ T
+ p
+ ' "${out_file}" | \
+ while read -r line; do
+ reason=$(
+ echo "${line}" | \
+ xargs why-dont-you
+ )
+ if [ "$(echo "${reason}" | wc -l)" -le 5 ]; then
+ echo "${reason}"
+ else
+ echo "${reason}" | \
+ head -n5
+ printf '... (%s lines total)\n' "$(echo "${reason}" | wc -l)"
+ fi > \
+ "${out_file%/out}/in"
+ done
+ sed -i "/${regex}/d" "${out_file}"
+ fi
+ done
+ done
+ exit
+fi