https://svn.lrde.epita.fr/svn/lrde-tools/trunk
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Implement git-lrde dcommit.
* src/git-lrde (lrde_dcommit): Implement, using Alexandre's
dcommit script.
git-lrde | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
Index: src/git-lrde
--- src/git-lrde (revision 491)
+++ src/git-lrde (working copy)
@@ -84,11 +84,56 @@
EOF
}
+# FIXME: Factor lrde_dcommit and lrde_send_email.
+
# lrde_dcommit
# ------------
lrde_dcommit()
{
- die "Not implemented yet."
+ count=$((`git log | sed '/ git-svn-id: /q' | grep -c '^commit'` -
1))
+ test $count -gt 0 || die "No patch to send."
+
+ # Sender.
+ test -n "$FULLNAME" || die "No environment variable FULLNAME set."
+ test -n "$EMAIL" || die "No environment variable EMAIL set."
+ sender="$FULLNAME <$EMAIL>"
+
+ # Recipient.
+ # Look for a project mailing list e-mail address in Vcs helper.
+ for f in . .. ../.. ../../..; do
+ test -f "$f"/vcs/*.rb || continue
+ recipient=`sed -n 's/.*mail.*\[\(.*@.*\)\].*/\1/p' "$f"/vcs/*.rb`
+ test -z "$recipient" || break
+ done
+ if test -z "$recipient"; then
+ echo 1>&2 "Don't know where to mail patches."
+ exit 1
+ else
+ echo Mailing patches to $recipient
+ fi
+
+ # FIXME: Allow the sender to add his own message to the e-mail.
+
+ # Get the last commited N patches.
+ git format-patch -C --numbered-files HEAD~$count
+ # Send them to the Subversion server.
+ git svn dcommit
+ # Refresh the list of patches, to get their Subversion revisions.
+ git format-patch -C --numbered-files HEAD~$count
+
+ for i in `seq 1 $count`; do
+ rev=$(grep -E '^git-svn-id:.*@[^ ]+' $i | sed 's/.*@\([^
]\+\).*/\1/')
+ echo "Sending mail for $rev..."
+ (
+ echo "To: $recipient"
+ sed -e "1d" \
+ -e "/^Subject:/s/\[PATCH\]/$rev:/" \
+ -e "/^git-svn-id:/d" \
+ -e "s/^From: .*/From: $sender/" \
+ $i
+ rm -f $i
+ ) | /usr/sbin/sendmail -t
+ done
}
# lrde_send-email N