Last active
March 14, 2017 21:57
-
-
Save grahamc/b593f62ec4068e0165f4ce57a6ed4bd6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| msg_list() { | |
| query="tag:nixossec tag:needs-triage and date:2017-02-22.. and not tag:package-identified" | |
| notmuch search "$query" | tr '[:upper:]' '[:lower:]' | |
| } | |
| score_subject() { | |
| # For each word in the subject, search for a package by that name | |
| # sort by the number of hits | |
| # remove 0-hit words | |
| # pick the word with the fewest hits | |
| (for word in $(echo "$1" | tr ' ' "\n" | sort | uniq); do | |
| printf "%s\t%d\n" "$word" $(grep -i "$word" ./packages | wc -l); | |
| done) \ | |
| | sort -n -k2 \ | |
| | awk '$2 > 0 { print $1;}' \ | |
| | head -n1 \ | |
| | sed -e "s/^/+suggested:/" -e "s/$/ $thread/" | |
| } | |
| IFS=$'\n'; | |
| (for msg in $(msg_list); do | |
| thread=$(echo "$msg" | cut -d' ' -f1); | |
| subj=$(echo "$msg" \ | |
| | cut -d\; -f2 \ | |
| | rev | cut -d\( -f2- | rev \ | |
| | cut -d\] -f2 \ | |
| | sed -e 's/[^A-Za-z0-9._-]/ /g' \ | |
| | sed -e 's/\s-/ /g'); | |
| echo "# $thread: $subj"; | |
| echo "# $msg"; | |
| score_subject "$subj"; | |
| done) | notmuch tag --batch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment