[or-cvs] [githax/master] Add email-everyone hook, and teach it to munge mails to get on to or-cvs

Nick Mathewson nickm at seul.org
Sun Apr 19 23:36:00 UTC 2009


Author: Nick Mathewson <nickm at torproject.org>
Subject: Add email-everyone hook, and teach it to munge mails to get on to or-cvs

---
 hooks/copyheaders.pl    |   14 ++++++++++++
 hooks/post-receive-diff |   55 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100755 hooks/copyheaders.pl
 create mode 100755 hooks/post-receive-diff

diff --git a/hooks/copyheaders.pl b/hooks/copyheaders.pl
new file mode 100755
index 0000000..a4485ab
--- /dev/null
+++ b/hooks/copyheaders.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl -w
+
+$from = "";
+$subject = "";
+
+while(<>) {
+  print;
+  chomp;
+  if (/^From: (.*)/) { $from = $1; }
+  if (/^Subject: \[[^\]]*\] *(.*)/) { $subject = $1; }
+  if (/^$/) { print "Author: $from\nSubject: $subject\n\n"; last; }
+}
+
+while(<>)  { print; }
diff --git a/hooks/post-receive-diff b/hooks/post-receive-diff
new file mode 100755
index 0000000..1a255a7
--- /dev/null
+++ b/hooks/post-receive-diff
@@ -0,0 +1,55 @@
+#! /bin/sh
+#
+# Copyright (c) 2008 Adeodato Simó (dato at net.com.org.es)
+#
+# This software may be used and distributed according to the terms
+# of the MIT License, incorporated herein by reference.
+
+# Usage: make this script your post-receive hook, or exec this script
+# from there. If you need to execute more than one script against
+# post-receive's stdin, you can use pee(1), from the moreutils package.
+#
+# Set hooks.mailinglist to an address (or addresses, in RFC822 format).
+# You can set hooks.projectname too; if not present, it'll be guessed
+# from the directory name of the repo.
+#
+# Mail will be generated with git-format-patch, with the subject being:
+#
+#     Subject: [projname/branchname] First line of of the commit message.
+#
+# formail, which comes with procmail, is needed to split git-format-patch's
+# output into separate mails.
+
+# TODO: Do something with creation and deletion of refs, particularly tags.
+
+recipients=$(git config hooks.mailinglist)
+projectname=$(git config hooks.projectname)
+H_EXTRA=djgg34554
+H_EXTRA="ved: $H_EXTRA"
+H_EXTRA="Appro$H_EXTRA"
+
+if [ -z "$recipients" ]; then
+    echo >&2 '[hooks/post-receive] Error: hooks.mailinglist not specified'
+    exit 1
+fi
+
+if [ -z "$projectname" ]; then
+    projectname="$(pwd)"
+    projectname="${projectname##*/}"
+    projectname="${projectname%.git}"
+fi
+
+isnull () {
+    echo "$1" | grep -qE '^0+$'
+}
+
+while read oldrev newrev refname; do
+    if isnull "$oldrev" || isnull "$newrev"; then
+       	echo >&2 '[hooks/post-receive] Warning: creation or deletion of branches not supported'
+       	continue
+    fi
+
+    git-format-patch --subject-prefix="$projectname/${refname#refs/heads/}" \
+		     --stdout "$oldrev..$newrev" |
+		     formail -s /home/or/git-helpers/copyheaders.pl | formail -i "$H_EXTRA" -I "To: $recipients" -R From: Patch-Author: -I "From " -s /usr/sbin/sendmail -t
+done
-- 
1.5.6.5



More information about the tor-commits mailing list