https://svn.lrde.epita.fr/svn/lrde-tools/trunk
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Start a Git extension for LRDE needs.
* src/git-lrde: New script.
* src/Makefile.am (dist_bin_SCRIPTS): Add git-lrde.
Makefile.am | 1
git-lrde | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 155 insertions(+)
Index: src/git-lrde
--- src/git-lrde (revision 0)
+++ src/git-lrde (revision 0)
@@ -0,0 +1,154 @@
+#! /bin/sh
+
+# Git extensions for the usual LRDE workflow.
+#
+# git lrde dcommit
+# Run `svn dcommit' and send the patches to the project mailing list.
+#
+# git lrde send-email
+# Send the last N git-svn dcommited patches to the project mailing list.
+#
+# Adapted from Alexandre Duret-Lutz's `dcommit' script.
+
+
+# There must not be failures.
+set -e
+# This script's name.
+me=$(basename "$0")
+
+
+# ---------- #
+# Routines. #
+# ---------- #
+
+# seq [[FIRST] INCREMENT] LAST
+# ----------------------------
+# Unfortunately, seq (from the GNU coreutils) is not available in
+# Mac OS X, nor in Fink. Use this (weak) replacement instead.
+seq ()
+{
+ case $# in
+ 1) first=1; inc=1; last=$1 ;;
+ 2) first=$1; inc=1; last=$2 ;;
+ 3) first=$1; inc=$2; last=$3 ;;
+ *) return ;;
+ esac
+ sep=""
+ i=$first
+ result=""
+ while test $i -le $last
+ do
+ result="$result$sep$i"
+ sep=" "
+ i=$(expr $i + $inc)
+ done
+ echo "$result"
+}
+
+# stderr MESSAGE1 [MESSAGE2 ...]
+# ------------------------------
+stderr ()
+{
+ local i
+ for i
+ do
+ echo >&2 "$me: $i"
+ done
+}
+
+# die MESSAGE
+# -----------
+die ()
+{
+ stderr "$*"
+ exit 1
+}
+
+
+# ---------- #
+# git lrde #
+# ---------- #
+
+# usage
+# -----
+usage ()
+{
+ cat <<EOF
+git-lrde - git extensions for the usual LRDE workflow
+Usage: git lrde <command> [argument]
+
+Available commands:
+ dcommit Run \`git svn dcommit' and send e-project e-mails
+ send-email Send the last N dcommited patches (requires integer argument)
+
+EOF
+}
+
+# lrde_dcommit
+# ------------
+lrde_dcommit()
+{
+ die "Not implemented yet."
+}
+
+# lrde_send-email N
+# -----------------
+# FIXME: Instead of a numeric argument, we should allow a description
+# of the patches to be send (e.g. `HEAD~3').
+# Or we should allow one to pass a list of SVN revisions instead.
+lrde_send_email()
+{
+ count=$1
+ # FIXME: Ensure count is a positive integer.
+ test -n $count || usage
+ test $count -gt 0 || die "No patch to send."
+ echo "$count patches 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.
+
+ 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
+}
+
+
+# Driver.
+test $# -eq 0 && usage
+command="$1"
+shift
+case "$command" in
+ dcommit) lrde_dcommit "$@" ;;
+ send-email) lrde_send_email "$@" ;;
+ *) die "Unknown command: $command."
+esac
Property changes on: src/git-lrde
___________________________________________________________________
Added: svn:executable
+ *
Index: src/Makefile.am
--- src/Makefile.am (revision 490)
+++ src/Makefile.am (working copy)
@@ -28,6 +28,7 @@
cvssnap \
diffed \
g2b \
+git-lrde \
insist \
install-on \
prcs-commit \