GIT_AUTHOR_NAME="`getent passwd $(id -un)|cut -d: -f5|cut -d, -f1`"
fi
if test -z "$GIT_AUTHOR_EMAIL"; then
- GIT_AUTHOR_EMAIL="`id -un`@`hostname -f`"
+ GIT_AUTHOR_EMAIL="`id -un`@`cat /etc/mailname 2>/dev/null || hostname -f`"
fi
if test -z "$GIT_COMMITTER_NAME"; then
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
if [ -s "$tempfile" ]; then
(
- echo "From: git `hostname --fqdn` - Cron Daemon <root+git@`cat /etc/mailname`>"
+ echo "From: git `hostname --fqdn` - Cron Daemon <root+git@`cat /etc/mailname 2>/dev/null || hostname --fqdn`>"
echo "To: ${recipients}"
echo "Date: `date --rfc-2822`"
echo "Subject: git-status: `hostname --fqdn` - $0"
echo "Content-Type: text/plain; charset=utf-8"
echo ""
- echo "Voici la liste de modifications sur la machine `hostname --fqdn` qui n'ont pas encore été validées :"
+ echo "Liste de modifications sur la machine `hostname --fqdn`"
+ echo "qui n'ont pas encore été validées :"
echo "( voir http://wiki.auf.org/wikiteki/Git/SuiviDeConfiguration )"
echo ""
cat "$tempfile"
+auf-git-etc (1.5.2) stable; urgency=low
+
+ * Meilleure détection du domaine de courriels.
+ * Refonte (en awk) et amélioration du script de post-commit.
+
+ -- Progfou <jean-christophe.andre@auf.org> Thu, 23 Apr 2009 03:02:15 +0700
+
auf-git-etc (1.5.1) stable; urgency=low
* Ooops… Le message de statut aussi a changé… Allez hop : silence !
#!/bin/sh
recipients="root+git" # adresse pour l'envoi du mail
# On modifie un peu la sortie de git show :
-# 1) on insère "git hostname - " devant le nom en From:
-# 2) on remplace "[PATCH]" par "git-commit:" dans le champ Subject:
-# 3) on ajoute un champ To:
-# 4) on ajoute un champ Content-Type:
+# - on remplace le nom de l'expéditeur dans l'enveloppe par "root+git"
+# - on insère "git hostname - " devant le nom en From:
+# - on remplace "[PATCH]" par "git-commit:" dans le champ Subject:
+# - on ajoute un champ To:
+# - on ajoute des champs MIME (version, type & encodage)
# et on envoie le tout via sendmail
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-git show --pretty=email |
- sed -e '1,6s/^From: /From: git '`hostname -f`' - /' \
- -e '1,6s/^Subject: \[PATCH\]/Subject: git-commit:/' \
- -e '3iTo: '"${recipients}" \
- -e '4iContent-Type: text/plain; charset=utf-8' |
- head -c 16k | /usr/sbin/sendmail ${recipients}
+git show --pretty=email | awk '\
+BEGIN { v=0 ; t=0 ; e=0 }
+/^From / { sub(/ [^ ]+ /," root+git ") }
+/^From: / { sub(/:/,": git '"`hostname --fqdn`"' -") }
+/^Subject: / { sub(/\[PATCH\]/,"git-commit:") }
+/^MIME-Version: / { v=1 }
+/^Content-Type: / { t=1 }
+/^Content-Transfer-Encoding: / { e=1 }
+/^$/ {
+ print "To: '"${recipients}"'"
+ if (!v) { print "MIME-Version: 1.0" }
+ if (!t) { print "Content-Type: text/plain; charset=utf-8" }
+ if (!e) { print "Content-Transfer-Encoding: 8bits" }
+}
+{ print }
+' | head -c 16k | sendmail ${recipients}
exit 0