Skip to content

Commit

Permalink
Merge pull request #274 from dpmatthews/admin-emails
Browse files Browse the repository at this point in the history
Hooks scripts: set the from address in all emails
  • Loading branch information
wxtim authored Nov 26, 2021
2 parents 93b6f2a + 0240887 commit 331a53b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 15 deletions.
8 changes: 6 additions & 2 deletions sbin/post-commit-bg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 6 additions & 2 deletions sbin/post-revprop-change-bg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 6 additions & 2 deletions sbin/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions sbin/pre-revprop-change
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions t/svn-hooks/02-pre-commit.t
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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/
Expand Down
4 changes: 2 additions & 2 deletions t/svn-hooks/03-post-commit-bg.t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 331a53b

Please sign in to comment.