Here’s a simple script that i use to stay up to date about the latest progress in Yiis SVN repository on Google Code. Maybe it’s useful for someone.
Note: The script requires a svn command line client. Check the minimal configuration on top.
#!/usr/bin/php
<?php
// Email recipient
$email='your@email.com';
// Email subject
$subject='SVN-Report Yii';
// How far do we go back?
$interval='-7 day';
// SVN parameters
$svnUrl='http://yii.googlecode.com/svn/trunk';
$svnLogCommand='svn log -r {%s}:HEAD --xml %s';
// Gooogle Issue URL:
$issueUrl='https://code.google.com/feeds/issues/p/yii/issues/full?id=%d';
// Prepare date
$date=new DateTime;
$date->modify($interval);
// Prepare email body message
$body=sprintf("Yii SVN-Logs for '%s' since %s:\n\n",$svnUrl,$date->format('d.m.Y'));
// Fetch SVN log as XML
$output=array();
exec( sprintf($svnLogCommand,$date->format('Ymd'),$svnUrl),$output);
$xml=new SimpleXMLElement(implode("\n",$output));
// Compose email body
if (isset($xml->logentry))
{
foreach($xml->logentry as $entry)
{
$body .= sprintf("%5d (%s): %s\n",(int)$entry['revision'],$entry->author,$entry->msg);
// Check for issue # in commit message:
if (preg_match('/issue.*(\d{4,5})/',$entry->msg,$m))
$body .= sprintf(" #%d: %s\n",$m[1],queryGoogleIssueTitle($m[1]));
$body .= "\n";
}
}
// Send email
mail($email,$subject,$body);
// Query for the title of a yii issue
function queryGoogleIssueTitle($id)
{
global $issueUrl;
if(($issue=@file(sprintf($issueUrl,(int)$id)))===false)
return "--- Could not fetch issue $id ---";
$xml=new SimpleXmlElement(implode("\n",$issue));
return $xml->entry->title;
}