diff --git a/sbin/post-commit-bg b/sbin/post-commit-bg index f28a01a7..8068a8fb 100755 --- a/sbin/post-commit-bg +++ b/sbin/post-commit-bg @@ -179,8 +179,12 @@ main() { if ! main 1>$LOG_REV 2>&1; then if [[ -n ${FCM_SVN_HOOK_ADMIN_EMAIL:-} ]]; then - mail -s "[$THIS] $REPOS@$REV" "$FCM_SVN_HOOK_ADMIN_EMAIL" <"$LOG_REV" \ - || true + FROM= + if [[ -n ${FCM_SVN_HOOK_NOTIFICATION_FROM:-} ]]; then + FROM="-r${FCM_SVN_HOOK_NOTIFICATION_FROM:-}" + fi + mail "$FROM" -s "[$THIS] $REPOS@$REV" \ + "$FCM_SVN_HOOK_ADMIN_EMAIL" <"$LOG_REV" || true fi fi cat "$LOG_REV" diff --git a/sbin/post-revprop-change-bg b/sbin/post-revprop-change-bg index 32da1c14..46ded75c 100755 --- a/sbin/post-revprop-change-bg +++ b/sbin/post-revprop-change-bg @@ -102,8 +102,12 @@ main() { } if ! main 1>$LOG_TMP 2>&1 && [[ -n ${FCM_SVN_HOOK_ADMIN_EMAIL:-} ]]; then - mail -s "[ERROR $THIS] $NAME" "$FCM_SVN_HOOK_ADMIN_EMAIL" <"$LOG_TMP" \ - || true + FROM= + if [[ -n ${FCM_SVN_HOOK_NOTIFICATION_FROM:-} ]]; then + FROM="-r${FCM_SVN_HOOK_NOTIFICATION_FROM:-}" + fi + mail "$FROM" -s "[ERROR $THIS] $NAME" \ + "$FCM_SVN_HOOK_ADMIN_EMAIL" <"$LOG_TMP" || true fi cat "$LOG_TMP" diff --git a/sbin/pre-commit b/sbin/pre-commit index f854fcae..b06e07a7 100755 --- a/sbin/pre-commit +++ b/sbin/pre-commit @@ -108,8 +108,12 @@ begin 1>"${LOG_TXN}" 2>&1 LOG_TXN_SIZE="$(stat -c '%s' "${LOG_TXN}")" if ! main 1>>"${LOG_TXN}" 2>&1; then if [[ -n ${FCM_SVN_HOOK_ADMIN_EMAIL:-} ]]; then - mail -s "[$THIS] $REPOS@$TXN" "$FCM_SVN_HOOK_ADMIN_EMAIL" <"$LOG_TXN" \ - || true + FROM= + if [[ -n ${FCM_SVN_HOOK_NOTIFICATION_FROM:-} ]]; then + FROM="-r${FCM_SVN_HOOK_NOTIFICATION_FROM:-}" + fi + mail "$FROM" -s "[$THIS] $REPOS@$TXN" \ + "$FCM_SVN_HOOK_ADMIN_EMAIL" <"$LOG_TXN" || true fi cat "$LOG_TXN" cat "$LOG_TXN" >&2 diff --git a/sbin/pre-revprop-change b/sbin/pre-revprop-change index 1ed98bd3..1cd45180 100755 --- a/sbin/pre-revprop-change +++ b/sbin/pre-revprop-change @@ -75,8 +75,12 @@ if ! grep -q "$ACTION *$PROPNAME" <<<"$OK_CHANGES"; then echo "[$ACTION $PROPNAME] permission denied." >&2 fi if [[ -n ${FCM_SVN_HOOK_ADMIN_EMAIL:-} ]]; then - mail -s "$NAME:$THIS" "$FCM_SVN_HOOK_ADMIN_EMAIL" <<<"[! $NOW] $@" \ - || true + FROM= + if [[ -n ${FCM_SVN_HOOK_NOTIFICATION_FROM:-} ]]; then + FROM="-r${FCM_SVN_HOOK_NOTIFICATION_FROM:-}" + fi + mail "$FROM" -s "$NAME:$THIS" \ + "$FCM_SVN_HOOK_ADMIN_EMAIL" <<<"[! $NOW] $@" || true fi echo "[! $NOW] $@" exit 1 diff --git a/t/svn-hooks/02-pre-commit.t b/t/svn-hooks/02-pre-commit.t index 64e35836..26465c02 100755 --- a/t/svn-hooks/02-pre-commit.t +++ b/t/svn-hooks/02-pre-commit.t @@ -76,7 +76,7 @@ file_cmp "$TEST_KEY.svnperms.py.out" svnperms.py.out <<__OUT__ __OUT__ date2datefmt mail.out >"$TEST_KEY.mail.out.expected" file_cmp "$TEST_KEY.mail.out" "$TEST_KEY.mail.out.expected" <<__LOG__ --s [pre-commit] $REPOS_PATH@$TXN your.admin.team +-rnotifications@localhost -s [pre-commit] $REPOS_PATH@$TXN your.admin.team YYYY-mm-ddTHH:MM:SSZ+ $TXN by $USER A file1 Access denied! @@ -106,7 +106,7 @@ __LOG__ run_fail "$TEST_KEY.svnperms.py.out" test -e svnperms.py.out date2datefmt mail.out >"$TEST_KEY.mail.out.expected" file_cmp "$TEST_KEY.mail.out" "$TEST_KEY.mail.out.expected" <<__LOG__ --s [pre-commit] $REPOS_PATH@$TXN your.admin.team +-rnotifications@localhost -s [pre-commit] $REPOS_PATH@$TXN your.admin.team YYYY-mm-ddTHH:MM:SSZ+ $TXN by $USER A file1 foo: permission configuration file not found. @@ -166,7 +166,7 @@ __LOG__ date2datefmt mail.out | sed 's/\(size \).*\(MB exceeds\)/\1??\2/' \ >"$TEST_KEY.mail.out.expected" file_cmp "$TEST_KEY.mail.out.expected" "$TEST_KEY.mail.out.expected" <<__OUT__ --s [pre-commit] $REPOS_PATH@$TXN your.admin.team +-rnotifications@localhost -s [pre-commit] $REPOS_PATH@$TXN your.admin.team YYYY-mm-ddTHH:MM:SSZ+ $TXN by $USER A file3 foo@$TXN: changeset size ??MB exceeds 10MB. @@ -220,7 +220,7 @@ __OUT__ date2datefmt mail.out | sed 's/\(size \).*\(MB exceeds\)/\1??\2/' \ >"$TEST_KEY.mail.out.expected" file_cmp "$TEST_KEY.mail.out.expected" "$TEST_KEY.mail.out.expected" <<__OUT__ --s [pre-commit] $REPOS_PATH@$TXN your.admin.team +-rnotifications@localhost -s [pre-commit] $REPOS_PATH@$TXN your.admin.team YYYY-mm-ddTHH:MM:SSZ+ $TXN by $USER A file4 I am a blocker. @@ -278,7 +278,7 @@ A hello/branches/dev/nosuchuser/whatever/ __LOG__ date2datefmt mail.out >"$TEST_KEY.mail.out.expected" file_cmp "$TEST_KEY.mail.out" "$TEST_KEY.mail.out.expected" <<__LOG__ --s [pre-commit] $REPOS_PATH@$TXN your.admin.team +-rnotifications@localhost -s [pre-commit] $REPOS_PATH@$TXN your.admin.team YYYY-mm-ddTHH:MM:SSZ+ $TXN by $USER A hello/branches/dev/nosuchuser/ A hello/branches/dev/nosuchuser/whatever/ diff --git a/t/svn-hooks/03-post-commit-bg.t b/t/svn-hooks/03-post-commit-bg.t index c2d51bfc..2ca33663 100755 --- a/t/svn-hooks/03-post-commit-bg.t +++ b/t/svn-hooks/03-post-commit-bg.t @@ -211,7 +211,7 @@ date2datefmt mail.out \ | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ >"$TEST_KEY.mail.out" file_cmp "$TEST_KEY.mail.out" "$TEST_KEY.mail.out" <<__LOG__ --s [post-commit-bg] $REPOS_PATH@$REV fcm.admin.team +-rnotifications@localhost -s [post-commit-bg] $REPOS_PATH@$REV fcm.admin.team YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) @@ -244,7 +244,7 @@ date2datefmt mail.out \ | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ >"${TEST_KEY}.mail.out" file_cmp "${TEST_KEY}.mail.out" "${TEST_KEY}.mail.out" <<__LOG__ --s [post-commit-bg] ${REPOS_PATH}@${REV} fcm.admin.team +-rnotifications@localhost -s [post-commit-bg] ${REPOS_PATH}@${REV} fcm.admin.team YYYY-mm-ddTHH:MM:SSZ+ ${REV} by ${USER} svnadmin dump -r${REV} --incremental --deltas ${REPOS_PATH} | gzip \\ | (dd 'conv=fsync' "of=${PWD}/svn-dumps/foo-${REV}-tmp.gz" 2>/dev/null)