Benutzer-Werkzeuge

Webseiten-Werkzeuge


pc:svncommitnotify

SVN Commit mit Notify

abgekuckt von http://ten-fingers-and-a-brain.com/2012/01/subversion-post-commit-hook-e-mail-report-script-that-sends-the-diff-as-an-attachment/

und hier nur sicherheitshalber gesichtert. Das Script zum Erzeugen des Commits

commit-report.sh
#!/bin/bash
 
# taken from http://ten-fingers-and-a-brain.com/2012/01/subversion-post-commit-hook-e-mail-report-script-that-sends-the-diff-as-an-attachment/
FROMADDRESS="svn@`hostname --fqdn`"
 
USAGE="Usage: `basename $0` -d PATH -mailto MAILTO\n\nCreates a commit report and sends it via E-mail\n\nValid options:\n\n\t-d PATH         : specify repository path PATH (required)\n\t-mailto MAILTO  : specify report recipients MAILTO,\n\t                  comma-separated (required)\n\t-rev ARG        : specify repository revision ARG, defaults to\n\t                  youngest revision\n\t-name ARG       : specify repository nice name ARG, defaults to\n\t                  basename of PATH\n\n"
 
if [ $# -eq 0 ]
then
  echo -e >&2 "$USAGE"; exit 3;
fi
 
REPO=""
MAILTO=""
REV=""
NAME=""
 
while [ $# -gt 0 ]
do
  case "$1" in
    -d)       REPO="$2";    shift;;
    -mailto)  MAILTO="$2";  shift;;
    -rev)     REV="$2";     shift;;
    -name)    NAME="$2";    shift;;
    *) echo -e >&2 "$USAGE"; exit 3;;
  esac
  if [ $# -eq 0 ]
  then
    echo >&2 "`basename $0`: missing argument"; exit 3;
  fi
  shift
done
 
if [ -z $REPO ]
then
  echo >&2 "`basename $0`: missing required option -d"; exit 3;
fi
 
if [ -z $MAILTO ]
then
  echo >&2 "`basename $0`: missing required option -mailto"; exit 3;
fi
 
if [ -z $REV ]
then
  REV=`svnlook youngest $REPO`
fi
 
FILENAME=`basename $REPO`
 
if [ -z $NAME ]
then
  NAME="SVN: $FILENAME"
fi
 
LOG=`svnlook log $REPO -r $REV`
LOG1=`svnlook log $REPO -r $REV | head -n1`
CHANGED=`svnlook changed $REPO -r $REV`
AUTHOR=`svnlook author $REPO -r $REV`
REVDATE=`svnlook date $REPO -r $REV`
 
BOUNDARY=_`date | md5sum | cut -d\  -f1`_
 
/usr/sbin/sendmail -f $FROMADDRESS -t <<EOF
Content-Type: multipart/mixed;
        boundary="_001$BOUNDARY"
From: $FROMADDRESS
To: $MAILTO
Subject: [$NAME][$REV] $LOG1
Date: `date -R`
MIME-Version: 1.0
 
--_001$BOUNDARY
Content-Type: multipart/alternative;
        boundary="_002$BOUNDARY"
 
--_002$BOUNDARY
Content-Type: text/plain
 
Revision
    $REV
Author
    $AUTHOR
Commit Date
    $REVDATE
 
== Log Message ==
 
$LOG
 
== Changes ==
 
$CHANGED
 
--_002$BOUNDARY
Content-Type: text/html
 
<dl>
<dt>Revision</dt><dd>$REV</dd>
<dt>Author</dt><dd>$AUTHOR</dd>
<dt>Commit Date</dt><dd>$REVDATE</dd>
</dl>
 
<h3>Log Message</h3><pre>$LOG</pre>
 
<h3>Changes</h3><pre>$CHANGED</pre>
 
--_002$BOUNDARY--
 
--_001$BOUNDARY
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$FILENAME-$REV.diff.gz"
 
`svnlook diff $REPO -r $REV | gzip | base64`
 
--_001$BOUNDARY--
EOF

und das passende hook script für das hooks/verzeichnis:

post-commit
#!/bin/sh
/var/www/vhosts/saas1205w1.saas-secure.com/anon_ftp/incoming/commit-report.sh -d "$1" -mailto "steffen@koehlers.de" -rev "$2"
 
# repository_dir = /var/www/vhosts/saas1205w1.saas-secure.com/httpdocs/files/svn/Trac
pc/svncommitnotify.txt · Zuletzt geändert: 2012/07/07 13:13 von admin