On Wed, Jul 23, 2008 at 8:22 AM, Raido <[EMAIL PROTECTED]> wrote:
>
> 1) Is it even possible to get commit messages text with php ? Since I can't
> find the file where commit messages are.

    Just a quick answer to this: in your directory of your project
repo, go into the hooks/ subdirectory.  In there, you'll find a
post-commit.tmpl file.  Remove the .tmpl extension and chmod 755
post-commit (if on *NIX).  When a commit is made, post-commit will be
executed by SVN.

    Conversely, if you want the script to execute on a different
trigger, just use a different name for the script, including
pre-commit, pre-lock, post-lock, post-revprop-change, et cetera.

    One of my post-commit scripts looks like this (with names changed
to protect the innocent):

#!/bin/bash
REPOS=$1
REV=$2
AUTHOR=`/usr/bin/svnlook author -r "$REV" "$REPOS"`
CHANGED=`/usr/bin/svnlook changed -r "$REV" "$REPOS"`
DIFF=`/usr/bin/svnlook diff -r "$REV" "$REPOS"`
/usr/bin/php -q /home/repos/sites/example-com/hooks/post-commit.php
"$REPOS" "$REV" "$AUTHOR" "$CHANGED" "$DIFF"


    And then, the PHP script it calls (post-commit.php) from the
shellscript above:

#!/usr/bin/php -q
<?php

$repo = $argv[1];
$rev = $argv[2];
$username = $argv[3];
$changes = $argv[4];
$diff = $argv[5];
$datetime = date("D, j F, Y")." at ".date("H:i:s T");

$to = "[EMAIL PROTECTED]";

$subject = "[SVN] Commit by ".$username;

$body  = "\n";
$body .= "\tChanges have been made to the SVN repository.  The
revision number is now ".$rev.".  Details follow.\n";
$body .= "\n";
$body .= "Committed at ".$datetime."\n";
$body .= "Committed By: ".$username."\n";
$body .= "Repository: ".$repo."\n";
$body .= "Revision # ".$rev."\n";
$body .= "\n\n";
$body .= "List of changes: \n";
$body .= $changes."\n";
$body .= "\n\n";
$body .= "Differences:\n";
$body .= $diff."\n";
$body .= "\n";

$headers  = "From: \"SVN: ".$username."\" <[EMAIL PROTECTED]>\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";

mail($to,$subject,$body,$headers);
?>

-- 
</Daniel P. Brown>
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to