SVN log by developer

Задача очень типовая: посмотреть список коммитов девелоперов, желательно красиво.

Требует colordiff’а (спасибо Антону Фёдорову).


 */

// Checking the args
if (isset($argv[1]))
{
  $author = $argv[1];
}
else
{
  echo "Usage:\n";
  echo "svnlogbyuser.php DEV [FULL]\n";
  die(-1);
}
$brief = (isset($argv[2])) ? false : true;

// Getting the data
$xml = simplexml_load_string(`svn log -r HEAD:0 -v --xml`);
$totalChanged = 0;

// Parsing them using XPath and, if required, svn and colordiff
foreach ($xml->xpath("/log/logentry[author = '$author']") as $node)
{
  $revision = $node['revision'];
  $previousRevision = $revision - 1;
  $date = date(DATE_RFC2822, strtotime((string)$node->date));
  printf("\nRevision %d, %s at %s\n", $revision, $author, $date);
  foreach($node->paths->path as $path) {
    $totalChanged++;
    printf("%s\n", $path);
    if (!$brief)
    {
      printf("%s\n\n", `svn diff -r $previousRevision:$revision ^/$path | colordiff`);
    }
  }
}
printf("Total changed %d by %s\n", $totalChanged, $author);

?>
Posted on September 11, 2009 at 4:34 PM by Dinexi · Permalink
In: главная · Tagged with: ,

Leave a Reply