diff options
| author | Dan Fandrich <danf@mageia.org> | 2025-11-14 18:15:52 -0800 |
|---|---|---|
| committer | Dan Fandrich <danf@mageia.org> | 2025-11-14 21:18:30 -0800 |
| commit | 155a610ee6bd0b2b8369e81448adb4d3f1084740 (patch) | |
| tree | 7786ef1c11c7a0e96e76946f34d3ead94e4a71c8 /modules/subversion/templates/nonmaintainer_notify.sh | |
| parent | bd20134a0608ca1e81069bb4586df20899eb8a15 (diff) | |
| download | puppet-master.tar puppet-master.tar.gz puppet-master.tar.bz2 puppet-master.tar.xz puppet-master.zip | |
If someone other than the registered maintainer of a package submits a
change to that package, notify the maintainer. These notifications are
skipped for robot changes and bulk changes where many packages are
changed at once.
Diffstat (limited to 'modules/subversion/templates/nonmaintainer_notify.sh')
| -rw-r--r-- | modules/subversion/templates/nonmaintainer_notify.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/modules/subversion/templates/nonmaintainer_notify.sh b/modules/subversion/templates/nonmaintainer_notify.sh new file mode 100644 index 00000000..e98d44be --- /dev/null +++ b/modules/subversion/templates/nonmaintainer_notify.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Send an e-mail to the maintainer of a package someone else has committed to. +# Exit on any error +set -e +set -o pipefail + +# Maximum number of packages changed in a single commit and still notify people +readonly MAXCHANGES=10 + +# Location of the maintdb database +readonly MAINTDB=/var/www/bs/data/maintdb.txt + +# Repository base directory +readonly REPOS="$1" + +# Revision of the change +readonly REV="$2" + +# Author of the commit +readonly AUTHOR="$(svnlook author -r "$REV" "$REPOS")" + +if [[ "$AUTHOR" == "schedbot" || "$AUTHOR" == "umeabot" ]]; then + # We don't send any e-mails from these automated committers + exit 0 +fi + +PKGSLIST="$(mktemp)" +trap 'rm -f "$PKGSLIST"' EXIT + +# Only look at changes in package files +svnlook dirs-changed -r "$REV" "$REPOS" | \ +pcregrep -o1 -o2 '^(?:(?:cauldron|misc)/([-+._a-zA-Z0-9]+)/)|(?:(?:updates|backports)/(?:[^/ ]+)/([-+._a-zA-Z0-9]+))' | \ +sort -u > "$PKGSLIST" +if [[ "$(wc -l "$PKGSLIST" | awk '{print $1}')" -gt "$MAXCHANGES" ]]; then + # A bunch of directories were changed at once, possibly in some kind of + # bulk operation. Ignore these entirely to avoid spamming people. + echo Too many packages were changed. Not notifying the maintainers. 1>&2 + exit 0 +fi + +# Send up to one e-mail per package modified in the commit +for PACKAGE in $(cat "$PKGSLIST"); do + MAINTAINER="$(awk '{if ($1 == "'"$PACKAGE"'") print $2}' "$MAINTDB")" + # Only notify if the commit author is not the maintainer + if [[ -n "$MAINTAINER" && "$MAINTAINER" != "nobody" && "$MAINTAINER" != "$AUTHOR" ]]; then + + svnnotify \ + --repos-path "$REPOS" \ + --revision "$REV" \ + --subject-cx \ + --no-first-line \ + --handler HTML::ColorDiff \ + --header "The user $AUTHOR has submitted a change to a package for which you are the registered maintainer." \ + --revision-url "https://svnweb.<%= @domain %>/packages/?revision=%s&view=revision" \ + --author-url "https://people.<%= @domain %>/u/%s.html" \ + --to "$MAINTAINER@<%= @domain %>" \ + --from "subversion_noreply@ml.<%= @domain %>" + + fi +done |
