Yii Project SVN reporter

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;

}



what does it do?

you know http://code.google.com/p/yii/source/list ?

there you can even add comments to the source-code

The script just sends you a weekly report about SVN activity. It also checks the commit messages for issue numbers and fetches the title of found issues, too.

It’s rather a convenience script to remind me about news in the SVN repository.

It will create report from latest commited changes on project - e.g.:

Yii SVN-Logs for ‘http://yii.googlecode.com/svn/trunk’ since 25.12.2010:

2772 (alexander.makarow): comment.create: missing views folder in a view path

2773 (jefftulsa): Issue 1886: removing the first two lines of the .htaccess example as they are not explicitly relevant to the apache url re-writing process.

2774 (qiang.xue): updated Croatian translations.

2775 (mdomba): Fixed captcha->checkRequirements() documentation - was not showing it

2776 (qiang.xue): (Fixes issue 1929)

#1929: --- Could not fetch issue 1929 ---

2777 (qiang.xue): (Fixes issue 1920)

#1920: --- Could not fetch issue 1920 ---

2778 (mdomba): missing dot

2779 (qiang.xue): doc fix.

2780 (qiang.xue): (Fixes issue 1931)

#1931: --- Could not fetch issue 1931 ---

2781 (qiang.xue): (Fixes issue 1902)

#1902: --- Could not fetch issue 1902 ---

2782 (qiang.xue): (Fixes issue 1914)

#1914: --- Could not fetch issue 1914 ---

2783 (qiang.xue): (Fixes issue 1897)

#1897: --- Could not fetch issue 1897 ---

2784 (qiang.xue): (Fixes issue 1879)

#1879: --- Could not fetch issue 1879 ---

2785 (qiang.xue): (Fixes issue 1899)

#1899: --- Could not fetch issue 1899 ---

2786 (qiang.xue): (Fixes issue 1888)

#1888: --- Could not fetch issue 1888 ---

2787 (qiang.xue): (Fixes issue 1872)

#1872: --- Could not fetch issue 1872 ---

2788 (qiang.xue): (Fixes issue 1842)

#1842: --- Could not fetch issue 1842 ---

2789 (mdomba): Fixes issue 1895

#1895: --- Could not fetch issue 1895 ---

2790 (mdomba): Added documentations that goes to the method summary table…

2791 (mdomba): Changed "int" to "integer" for consistency, in PHPDoc

2792 (alexander.makarow): Added sk to messages command

2793 (mdomba): Documented second parameter for CGridView->beforeAjaxRequest

2794 (sebathi): Fixed issue 1936

#1936: --- Could not fetch issue 1936 ---

2795 (alexander.makarow): documentation fixes

@lubosdz:

There seems to be a problem in your queryGoogleIssueTitle() method ("Could not fetch issue …"). The output should look like this: