From 6e71f6224c17b981f53c4f2bf79331f0a412240b Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Tue, 6 Nov 2007 20:01:02 +0100 Subject: [PATCH] Handle the and special tags. The tag is only valid in the `From:' field and in the `To:' field. These tags are meant to ease the use of the --use-log-file option introduced recently. You can generate a stub without even filling the `From:' and `To:' fields and let svn-wrapper do it for you. Feature requested by Akim Demaille (like the --use-log-file one). * get_mailto_property: New. Factored out of svn_commit. * svn_commit: Don't screw up the log file if --use-log-file is used several times without actually committing. Handle the and tags. Signed-off-by: Benoit Sigoure --- svn-wrapper.sh | 132 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 47 deletions(-) diff --git a/svn-wrapper.sh b/svn-wrapper.sh index 9b2e7a2..09b46f5 100755 --- a/svn-wrapper.sh +++ b/svn-wrapper.sh @@ -551,6 +551,64 @@ git_get_repos_info_() repos_root=$repos_url } +# Helper. Find the `mailto' property, be it an SVN property or a git-config +# option. Relies on the value of $change_log_dir and sets the values of +# $mailto (the value of the `mailto' property) and $to (a string to append in +# templates that contains the `To:' line, or an empty string if no mail must +# be sent). +get_mailto_property() +{ + test -d "$change_log_dir" || abort 'Internal error in get_mailto_property: + $change_log_dir not pointing to a directory' + if $git_mode; then + mailto=`git config svnw.mailto` + if [ x"$mailto" = x ] \ + && [ -f "$change_log_dir/.git/svn/git-svn/unhandled.log" ] + then + mailto=`grep mailto "$change_log_dir/.git/svn/git-svn/unhandled.log"` + sed_tmp='$!d;s/^.*+dir_prop: . mailto //;s/%40/@/g;s/%2C/,/g;s/%20/ /g;' + mailto=`echo "$mailto" | sed "$sed_tmp"` + fi + if [ x"$mailto" = x ]; then + warn 'No mailto property set for this repository. +If this is a git-svn repository, do this in a SVN working copy: + svn propset mailto maintainer1@foo.com,maint2@bar.com . +If this is a real git repository, do this: + git config svnw.mailto maintainer1@foo.com,maint2@bar.com' + fi + else + mailto=`$SVN propget mailto "$change_log_dir"` + fi + + if [ x"$mailto" = x ]; then + test x$new_user = xyes \ + && warn "no svn property mailto found in $change_log_dir + You might want to set default email adresses using: + svn propset mailto 'somebody@mail.com, foobar@example.com'\ + $change_log_dir" >&2 + # Try to be VCS-compatible and find a list of mails in a *.rb. + if [ -d "$change_log_dir/vcs" ]; then + mailto=`grep '.@.*\..*' "$change_log_dir"/vcs/*.rb \ + | tr '\n' ' ' \ + | sed 's/^.*[["]\([^["]*@[^]"]*\)[]"].*$/\1/' | xargs` + test x"$mailto" != x && test x$new_user = xyes \ + && notice "VCS-compat: found mailto: $mailto + in " "$change_log_dir"/vcs/*.rb + fi # end VCS compat + fi # end guess mailto + + # Ensure that emails are comma-separated. + mailto=`echo "$mailto" | sed 's/[ ;]/,/g' | tr -s ',' | sed 's/,/, /g'` + + to= + if [ x"$mailto" != xdont_send_mails ] && [ x"$mailto" != xnothx ]; then + to=" +To: $mailto" + fi +} + + + # ------------------------------- # # Hooks for standard SVN commands # # ------------------------------- # @@ -858,7 +916,10 @@ Would you like to resume it or proceed immediately?"; }; then } END { if (tlatbwbi_seen == 0) - print "--This line, and those below, will be ignored--"; + { + print "--This line, and those below, will be ignored--\n\n" \ + " Your ChangeLog entry will appear here."; + } }' "$tmp_log" >"$tmp_log.tmp" echo " --- @@ -904,45 +965,8 @@ If this is a real git repository, do this: fi test x"$projname" != x && projname=`echo "$projname" | sed '/[^ ]$/s/$/ /'` - if $git_mode; then - mailto=`git config svnw.mailto` - if [ x"$mailto" = x ] \ - && [ -f "$change_log_dir/.git/svn/git-svn/unhandled.log" ] - then - mailto=`grep mailto "$change_log_dir/.git/svn/git-svn/unhandled.log"` - sed_tmp='$!d;s/^.*+dir_prop: . mailto //;s/%40/@/g;s/%2C/,/g;s/%20/ /g;' - mailto=`echo "$mailto" | sed "$sed_tmp"` - fi - if [ x"$mailto" = x ]; then - warn 'No mailto property set for this repository. -If this is a git-svn repository, do this in a SVN working copy: - svn propset mailto maintainer1@foo.com,maint2@bar.com . -If this is a real git repository, do this: - git config svnw.mailto maintainer1@foo.com,maint2@bar.com' - fi - else - mailto=`$SVN propget mailto "$change_log_dir"` - fi + get_mailto_property - if [ x"$mailto" = x ]; then - test x$new_user = xyes \ - && warn "no svn property mailto found in $change_log_dir - You might want to set default email adresses using: - svn propset mailto 'somebody@mail.com, foobar@example.com'\ - $change_log_dir" >&2 - # Try to be VCS-compatible and find a list of mails in a *.rb. - if [ -d "$change_log_dir/vcs" ]; then - mailto=`grep '.@.*\..*' "$change_log_dir"/vcs/*.rb \ - | tr '\n' ' ' \ - | sed 's/^.*[["]\([^["]*@[^]"]*\)[]"].*$/\1/' | xargs` - test x"$mailto" != x && test x$new_user = xyes \ - && notice "VCS-compat: found mailto: $mailto - in " "$change_log_dir"/vcs/*.rb - fi # end VCS compat - fi # end guess mailto - - # Ensure that emails are comma-separated. - mailto=`echo "$mailto" | sed 's/[ ;]/,/g' | tr -s ',' | sed 's/,/, /g'` test x"$FULLNAME" = x && FULLNAME='Type Your Name Here' \ && warn_env FULLNAME test x"$EMAIL" = x && EMAIL='your.mail.here@FIXME.com' && warn_env EMAIL @@ -1010,11 +1034,6 @@ Instructions: else commit_instructions= fi - to= - if [ x"$mailto" != xdont_send_mails ] && [ x"$mailto" != xnothx ]; then - to=" -To: $mailto" - fi r_before_rev=r $git_mode && r_before_rev= test x"$extra_repos_info" = x || extra_repos_info=" @@ -1094,10 +1113,29 @@ vi: ft=diff:noet:tw=76:" >>"$tmp_log" if test x"$mail_to" = x; then send_a_mail=false else - mail_to=`echo "$mail_to" | sed 's/^To: *//'` - ensure_not_empty '"To:" field of the mail' "$mail_to" + mail_to=`echo "$mail_to" | sed 's/^To: *//;s///'` + # If there is a in the 'To:' line, we must expand it. + case $mail_to in #( + *''*) + get_mailto_property + # Are we meant to send a mail? + case $to in #( + '') # No, don't send a mail. + mail_to= + send_a_mail=false + ;; #( + *) # Yes, send a mail. + mail_to=`echo "$mail_to" | sed "s##$mailto#g"` + ;; + esac + esac + $send_a_mail && ensure_not_empty '"To:" field of the mail' "$mail_to" fi - mail_from=`echo "$full_log" | sed '/^From: */!d;s///'` + + test x"$FULLNAME" = x && warn_env FULLNAME && FULLNAME=$USER + test x"$EMAIL" = x && warn_env EMAIL && EMAIL=$USER + myself=`echo "$FULLNAME <$EMAIL>" | sed "$sed_escape"` + mail_from=`echo "$full_log" | sed "/^From: */!d;s///;s@@$myself@g"` ensure_not_empty '"From:" field of the mail' "$mail_from" # ------------------------------------ # -- 2.11.4.GIT