3
* Svnblame report for PHP_CodeSniffer.
8
* @package PHP_CodeSniffer
9
* @author Gabriele Santini <gsantini@sqli.com>
10
* @author Greg Sherwood <gsherwood@squiz.net>
11
* @copyright 2009-2014 SQLI <www.sqli.com>
12
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
* @link http://pear.php.net/package/PHP_CodeSniffer
18
* Svnblame report for PHP_CodeSniffer.
23
* @package PHP_CodeSniffer
24
* @author Gabriele Santini <gsantini@sqli.com>
25
* @author Greg Sherwood <gsherwood@squiz.net>
26
* @copyright 2009-2014 SQLI <www.sqli.com>
27
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
* @version Release: 1.5.3
30
* @link http://pear.php.net/package/PHP_CodeSniffer
32
class PHP_CodeSniffer_Reports_Svnblame extends PHP_CodeSniffer_Reports_VersionControl
36
* The name of the report we want in the output
40
protected $reportName = 'SVN';
44
* Extract the author from a blame line.
46
* @param string $line Line to parse.
48
* @return mixed string or false if impossible to recover.
50
protected function getAuthor($line)
52
$blameParts = array();
53
preg_match('|\s*([^\s]+)\s+([^\s]+)|', $line, $blameParts);
55
if (isset($blameParts[2]) === false) {
59
return $blameParts[2];
65
* Gets the blame output.
67
* @param string $filename File to blame.
71
protected function getBlameContent($filename)
73
if (PHP_CODESNIFFER_VERBOSITY > 0) {
74
echo 'Getting SVN blame info for '.basename($filename).'... ';
77
$command = 'svn blame "'.$filename.'"';
78
$handle = popen($command, 'r');
79
if ($handle === false) {
80
echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
84
$rawContent = stream_get_contents($handle);
87
if (PHP_CODESNIFFER_VERBOSITY > 0) {
91
$blames = explode("\n", $rawContent);
95
}//end getBlameContent()