aboutsummaryrefslogtreecommitdiffstats
path: root/modules/subversion
diff options
context:
space:
mode:
Diffstat (limited to 'modules/subversion')
-rw-r--r--modules/subversion/manifests/repository.pp33
-rw-r--r--modules/subversion/templates/hook_sendmail.pl4
-rw-r--r--modules/subversion/templates/no_binary2
-rw-r--r--modules/subversion/templates/nonmaintainer_notify.sh62
-rw-r--r--modules/subversion/templates/restricted_to_user2
5 files changed, 88 insertions, 15 deletions
diff --git a/modules/subversion/manifests/repository.pp b/modules/subversion/manifests/repository.pp
index 77b32765..927ecfa1 100644
--- a/modules/subversion/manifests/repository.pp
+++ b/modules/subversion/manifests/repository.pp
@@ -22,13 +22,14 @@ define subversion::repository($group = 'svn',
$no_binary = false,
$restricted_to_user = false,
$syntax_check = '',
- $extract_dir = '') {
+ $extract_dir = '',
+ $nonmaintainer_mail = false) {
# check permissions
# https://svnbook.red-bean.com/nightly/fr/svn.serverconfig.multimethod.html
# $name ==> directory of the repo
include subversion::server
# TODO set umask -> requires puppet 2.7.0
- # unfortunatly, umask is required
+ # unfortunately, umask is required
# https://projects.puppetlabs.com/issues/4424
exec { "/usr/local/bin/create_svn_repo.sh ${name}":
user => 'root',
@@ -108,16 +109,26 @@ define subversion::repository($group = 'svn',
}
}
- if $extract_dir {
- subversion::hook::post_commit {"${name}|extract_dir":
- content => template('subversion/hook_extract.pl'),
- require => [Package['perl-SVN-Notify-Mirror']],
- }
- } else {
- file { "${name}/hooks/post-commit.d/extract_dir":
- ensure => absent,
- }
+ if $extract_dir {
+ subversion::hook::post_commit {"${name}|extract_dir":
+ content => template('subversion/hook_extract.pl'),
+ require => [Package['perl-SVN-Notify-Mirror']],
}
+ } else {
+ file { "${name}/hooks/post-commit.d/extract_dir":
+ ensure => absent,
+ }
+ }
+
+ if $nonmaintainer_mail {
+ subversion::hook::post_commit { "${name}|nonmaintainer_mail":
+ content => template('subversion/nonmaintainer_notify.sh'),
+ }
+ } else {
+ file { "${name}/hooks/post-commit.d/nonmaintainer_mail":
+ ensure => absent,
+ }
+ }
pre_commit_link { "${name}/hooks/pre-commit.d/no_empty_message": }
diff --git a/modules/subversion/templates/hook_sendmail.pl b/modules/subversion/templates/hook_sendmail.pl
index 81b786d2..cf3be6a4 100644
--- a/modules/subversion/templates/hook_sendmail.pl
+++ b/modules/subversion/templates/hook_sendmail.pl
@@ -8,7 +8,7 @@
with-diff: 1
max_diff_length: 20000
ticket_map:
- '\bmga#(\d+)\b': 'https://bugs.mageia.org/show_bug.cgi?id=%s'
+ '(\bmga#(\d+)\b)': 'https://bugs.mageia.org/show_bug.cgi?id=%s'
revision-url: "https://svnweb.mageia.org/packages/?revision=%s&view=revision"
subject_cx: 1
from: subversion_noreply@ml.<%= @domain %>
@@ -24,7 +24,7 @@
with-diff: 1
max_diff_length: 20000
ticket_map:
- '\bmga#(\d+)\b': 'https://bugs.mageia.org/show_bug.cgi?id=%s'
+ '(\bmga#(\d+)\b)': 'https://bugs.mageia.org/show_bug.cgi?id=%s'
revision-url: "https://svnweb.mageia.org/packages/?revision=%s&view=revision"
subject_cx: 1
from: subversion_noreply@ml.<%= @domain %>
diff --git a/modules/subversion/templates/no_binary b/modules/subversion/templates/no_binary
index a7f2eb94..284642e5 100644
--- a/modules/subversion/templates/no_binary
+++ b/modules/subversion/templates/no_binary
@@ -3,7 +3,7 @@
REP="$1"
TXN="$2"
-# Filter some binary files based on common filename extentions.
+# Filter some binary files based on common filename extensions.
# It does not fully prevent commit of binary files, this script is only
# here to avoid simple mistakes
if svnlook changed -t "$TXN" "$REP" | grep -qi '\.\(gz\|bz2\|xz\|lzma\|Z\|7z\|tar\|tgz\|zip\|jpg\|gif\|png\|ogg\|mp3\|wav\|rar\|pdf\)$'
diff --git a/modules/subversion/templates/nonmaintainer_notify.sh b/modules/subversion/templates/nonmaintainer_notify.sh
new file mode 100644
index 00000000..46ca54e8
--- /dev/null
+++ b/modules/subversion/templates/nonmaintainer_notify.sh
@@ -0,0 +1,62 @@
+#!/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 changed -r "$REV" "$REPOS" | \
+sed 's/^....//' | \
+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; exit;}}' "$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 Alternative \
+ --alternative HTML::ColorDiff \
+ --header "The user $AUTHOR has submitted a change to a package for which you ($MAINTAINER) 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
diff --git a/modules/subversion/templates/restricted_to_user b/modules/subversion/templates/restricted_to_user
index 5c70132e..98297627 100644
--- a/modules/subversion/templates/restricted_to_user
+++ b/modules/subversion/templates/restricted_to_user
@@ -6,7 +6,7 @@ TXN="$2"
author=$(svnlook author -t "$TXN" "$REP")
if [ "$author" != '<%= restricted_to_user %>' ]; then
- echo "this repository is restrected to user <%= restricted_to_user %>" >&2
+ echo "this repository is restricted to user <%= restricted_to_user %>" >&2
exit 1
fi