forked from marfrit/marfrit-packages
tools/lore-watch.sh: also watch dri-devel and linux-rockchip
Christian König (DMA-buf maintainer) tends to reply on dri-devel. Rockchip SoC people land on linux-rockchip. Adding both to the watched-inbox list, generalized the loop so the array is the only thing to edit when adding more. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+65
-49
@@ -1,71 +1,87 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# lore-watch — daily check for replies to mfritsche@reauktion.de threads on
|
# lore-watch — daily check for replies to mfritsche@reauktion.de threads
|
||||||
# linux-media public-inbox. Mails any matches to mfritsche@reauktion.de.
|
# across multiple lore.kernel.org public-inboxes. Mails any matches via
|
||||||
|
# msmtp.
|
||||||
#
|
#
|
||||||
# Started 2026-04-29 to track the vb2 dma_resv RFC series.
|
# Started 2026-04-29 to track the vb2 dma_resv RFC series.
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO=$HOME/.local/state/lore-watch/linux-media-pi.git
|
# List of public-inboxes to watch. Add more by appending here.
|
||||||
|
INBOXES=(
|
||||||
|
linux-media
|
||||||
|
dri-devel
|
||||||
|
linux-rockchip
|
||||||
|
)
|
||||||
|
|
||||||
STATE=$HOME/.local/state/lore-watch
|
STATE=$HOME/.local/state/lore-watch
|
||||||
mkdir -p "$STATE"
|
mkdir -p "$STATE"
|
||||||
|
|
||||||
if [ ! -d "$REPO" ]; then
|
|
||||||
git clone --bare --depth 200 https://lore.kernel.org/linux-media/0 "$REPO" >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If state is missing, seed it with current HEAD and exit (nothing to compare).
|
|
||||||
if [ ! -s "$STATE/last-seen.sha" ]; then
|
|
||||||
git -C "$REPO" fetch --depth 200 origin >/dev/null 2>&1 || true
|
|
||||||
git -C "$REPO" rev-parse FETCH_HEAD > "$STATE/last-seen.sha" 2>/dev/null || \
|
|
||||||
git -C "$REPO" rev-parse HEAD > "$STATE/last-seen.sha"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
LAST=$(cat "$STATE/last-seen.sha")
|
|
||||||
git -C "$REPO" fetch --depth 200 origin master >/dev/null 2>&1 || \
|
|
||||||
git -C "$REPO" fetch --depth 200 origin >/dev/null 2>&1
|
|
||||||
HEAD=$(git -C "$REPO" rev-parse FETCH_HEAD 2>/dev/null || git -C "$REPO" rev-parse HEAD)
|
|
||||||
|
|
||||||
if [ "$LAST" = "$HEAD" ]; then
|
|
||||||
exit 0 # no new messages
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Walk new commits, only flag messages where the user's email appears in
|
|
||||||
# headers (To/Cc/From). This catches replies (which keep the original
|
|
||||||
# To/Cc per kernel convention) without matching unrelated videobuf2 threads.
|
|
||||||
TMPDIR=$(mktemp -d)
|
TMPDIR=$(mktemp -d)
|
||||||
trap 'rm -rf "$TMPDIR"' EXIT
|
trap 'rm -rf "$TMPDIR"' EXIT
|
||||||
|
|
||||||
RANGE="$LAST..$HEAD"
|
GLOBAL_HITS=0
|
||||||
HITS=0
|
|
||||||
|
|
||||||
while read -r SHA; do
|
for INBOX in "${INBOXES[@]}"; do
|
||||||
MSG=$(git -C "$REPO" show "$SHA:m" 2>/dev/null) || continue
|
REPO=$STATE/$INBOX-pi.git
|
||||||
HDR=$(printf '%s\n' "$MSG" | sed '/^$/q')
|
STATE_FILE=$STATE/last-seen-$INBOX.sha
|
||||||
if printf '%s' "$HDR" | grep -qi "mfritsche@reauktion\.de"; then
|
|
||||||
{
|
if [ ! -d "$REPO" ]; then
|
||||||
printf 'commit: %s\n' "$SHA"
|
git clone --bare --depth 200 "https://lore.kernel.org/$INBOX/0" "$REPO" >/dev/null 2>&1 || {
|
||||||
printf '%s\n' "$HDR" | grep -iE '^(From|Subject|Date|Message-Id|In-Reply-To):' | head -10
|
printf 'lore-watch: clone of %s failed, skipping\n' "$INBOX" >&2
|
||||||
printf '\n--- snippet ---\n'
|
continue
|
||||||
printf '%s\n' "$MSG" | sed -n '/^$/,${p;}' | head -40
|
}
|
||||||
printf '\n=========================================================\n\n'
|
|
||||||
} >> "$TMPDIR/digest.txt"
|
|
||||||
HITS=$((HITS + 1))
|
|
||||||
fi
|
fi
|
||||||
done < <(git -C "$REPO" log --reverse --format=%H "$RANGE")
|
|
||||||
|
|
||||||
# Update state regardless of hits, so next run only sees newer messages
|
# Seed state on first sight (no compare possible yet)
|
||||||
echo "$HEAD" > "$STATE/last-seen.sha"
|
if [ ! -s "$STATE_FILE" ]; then
|
||||||
|
git -C "$REPO" fetch --depth 200 origin >/dev/null 2>&1 || true
|
||||||
|
git -C "$REPO" rev-parse FETCH_HEAD > "$STATE_FILE" 2>/dev/null || \
|
||||||
|
git -C "$REPO" rev-parse HEAD > "$STATE_FILE"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$HITS" -gt 0 ]; then
|
LAST=$(cat "$STATE_FILE")
|
||||||
|
git -C "$REPO" fetch --depth 200 origin master >/dev/null 2>&1 || \
|
||||||
|
git -C "$REPO" fetch --depth 200 origin >/dev/null 2>&1 || {
|
||||||
|
printf 'lore-watch: fetch of %s failed, skipping\n' "$INBOX" >&2
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
HEAD=$(git -C "$REPO" rev-parse FETCH_HEAD 2>/dev/null || git -C "$REPO" rev-parse HEAD)
|
||||||
|
|
||||||
|
if [ "$LAST" = "$HEAD" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
HITS_HERE=0
|
||||||
|
while read -r SHA; do
|
||||||
|
MSG=$(git -C "$REPO" show "$SHA:m" 2>/dev/null) || continue
|
||||||
|
HDR=$(printf '%s\n' "$MSG" | sed '/^$/q')
|
||||||
|
if printf '%s' "$HDR" | grep -qi "mfritsche@reauktion\.de"; then
|
||||||
|
{
|
||||||
|
printf 'list: %s\n' "$INBOX"
|
||||||
|
printf 'commit: %s\n' "$SHA"
|
||||||
|
printf '%s\n' "$HDR" | grep -iE '^(From|Subject|Date|Message-Id|In-Reply-To):' | head -10
|
||||||
|
printf '\n--- snippet ---\n'
|
||||||
|
printf '%s\n' "$MSG" | sed -n '/^$/,${p;}' | head -40
|
||||||
|
printf '\n=========================================================\n\n'
|
||||||
|
} >> "$TMPDIR/digest.txt"
|
||||||
|
HITS_HERE=$((HITS_HERE + 1))
|
||||||
|
GLOBAL_HITS=$((GLOBAL_HITS + 1))
|
||||||
|
fi
|
||||||
|
done < <(git -C "$REPO" log --reverse --format=%H "$LAST..$HEAD")
|
||||||
|
|
||||||
|
echo "$HEAD" > "$STATE_FILE"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$GLOBAL_HITS" -gt 0 ]; then
|
||||||
{
|
{
|
||||||
printf 'Subject: [lore-watch] %d new linux-media message(s) referencing your threads\n' "$HITS"
|
printf 'Subject: [lore-watch] %d new lore message(s) referencing your threads\n' "$GLOBAL_HITS"
|
||||||
printf 'From: lore-watch <mfritsche@reauktion.de>\n'
|
printf 'From: lore-watch <mfritsche@reauktion.de>\n'
|
||||||
printf 'To: mfritsche@reauktion.de\n'
|
printf 'To: mfritsche@reauktion.de\n'
|
||||||
printf '\n'
|
printf '\n'
|
||||||
printf 'Daily lore.kernel.org/linux-media scan caught %d message(s) that\n' "$HITS"
|
printf 'Daily lore.kernel.org scan (lists: %s) caught %d message(s)\n' \
|
||||||
printf 'reference your address or vb2 dma_resv subject keywords:\n\n'
|
"$(IFS=,; printf '%s' "${INBOXES[*]}")" "$GLOBAL_HITS"
|
||||||
|
printf 'that reference your address:\n\n'
|
||||||
cat "$TMPDIR/digest.txt"
|
cat "$TMPDIR/digest.txt"
|
||||||
printf '\n-- \n(noether ~/.local/bin/lore-watch.sh, scheduled daily)\n'
|
printf '\n-- \n(noether ~/.local/bin/lore-watch.sh, scheduled daily)\n'
|
||||||
} | /usr/bin/msmtp -t
|
} | /usr/bin/msmtp -t
|
||||||
|
|||||||
Reference in New Issue
Block a user