Skip to content

Instantly share code, notes, and snippets.

@sudhanshuraheja
Created May 5, 2010 11:09
Show Gist options
  • Save sudhanshuraheja/390645 to your computer and use it in GitHub Desktop.
Save sudhanshuraheja/390645 to your computer and use it in GitHub Desktop.
<?php
function getRepoName($repo) {
return strtoupper(str_replace('/', '', str_replace('/svn/svn.localhost/', '', $repo)));
}
require_once('phpmail/class.phpmailer.php');
$repository = isset($argv[1]) ? $argv[1] : '';
$revision = isset($argv[2]) ? $argv[2] : '';
$author = strtoupper(exec('svnlook author ' . $repository));
$changed = exec('svnlook changed ' . $repository);
$comments = exec('svnlook log ' . $repository);
$diff = '';
$fp = popen('svnlook diff ' . $repository, "r");
while(!feof($fp)) {
$diff .= fread($fp, 1024);
flush();
}
pclose($fp);
$body = "
Hi,\n\n
$author has just committed
revision $revision in " . getRepoName($repository) . "
and said \n\n$comments.
\n\n\n\n
The following files have changed :\n\n$changed
\n\n\n\nThe changelog is given below $diff";
$mail = new PHPMailer();
$mail->From = 'svn@localhost';
$mail->FromName = 'SVN Server';
$mail->AddAddress('repo.admin@localhost', 'Repo Admin');
$mail->Subject = 'SVN Commit - ' . getRepoName($repository) . ' - Revision ' . $revision;
$mail->Body = $body;
if(!$mail->Send()) {
echo "Error sending: " . $mail->ErrorInfo;;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment