Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #11 from marcojanssen/new-filename-after-original-…
Browse files Browse the repository at this point in the history
…filename

Newer log format has new filename after original name
  • Loading branch information
fieg authored Nov 28, 2016
2 parents 3a1b0d1 + 640b8b4 commit bfcbd4a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/Webcreate/Vcs/Git/Parser/CliParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,15 @@ public function parseDiffOutput($output, array $arguments = array())

$retval = array();
foreach ($lines as $line) {
if (preg_match('/([ACDMRTUXB])\d*\s+(.*)?/', $line, $matches)) {
list($fullmatch, $x, $file) = $matches;
if (preg_match('/([ACDMRTUXB])(\d*)\s+(.*)?/', $line, $matches)) {
list($fullmatch, $status, $number, $filename) = $matches;

$file = new VcsFileInfo($file, $this->getClient()->getHead());
$file->setStatus($x);
if ($number && preg_match('/(.*\s)+(.*)/', $filename, $filenameMatches)) {
list($fullmatch, $originalName, $filename) = $filenameMatches;
}

$file = new VcsFileInfo($filename, $this->getClient()->getHead());
$file->setStatus($status);

$retval[] = $file;
} else {
Expand Down
23 changes: 19 additions & 4 deletions tests/Webcreate/Vcs/Git/Parser/CliParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ public function it_parses_diff_output()
{
$diffOutput = <<<EOT
A tests/Webcreate/Vcs/Git/Parser/CliParserTest.php
R Webcreate/Vcs/Svn/WorkingCopy.php
R062 Webcreate/Vcs/Svn/SvnAdmin.php
R Webcreate/Vcs/Svn/WorkingRename.php
R062 Webcreate/Vcs/Svn/WorkingCopy.php Webcreate/Vcs/Svn/WorkingRename.php
D Webcreate/Vcs/Svn/AbstractSvn.php
M Webcreate/Vcs/Svn.php
M001 Webcreate/Vcs/Svn.php
EOT;

$parsedDiff = $this->parser->parseDiffOutput(
Expand All @@ -43,10 +46,22 @@ public function it_parses_diff_output()

$fileInfo = next($parsedDiff);
$this->assertSame('R', $fileInfo->getStatus());
$this->assertSame('Webcreate/Vcs/Svn/WorkingCopy.php', $fileInfo->getPathname());
$this->assertSame('Webcreate/Vcs/Svn/WorkingRename.php', $fileInfo->getPathname());

$fileInfo = next($parsedDiff);
$this->assertSame('R', $fileInfo->getStatus());
$this->assertSame('Webcreate/Vcs/Svn/SvnAdmin.php', $fileInfo->getPathname());
$this->assertSame('Webcreate/Vcs/Svn/WorkingRename.php', $fileInfo->getPathname());

$fileInfo = next($parsedDiff);
$this->assertSame('D', $fileInfo->getStatus());
$this->assertSame('Webcreate/Vcs/Svn/AbstractSvn.php', $fileInfo->getPathname());

$fileInfo = next($parsedDiff);
$this->assertSame('M', $fileInfo->getStatus());
$this->assertSame('Webcreate/Vcs/Svn.php', $fileInfo->getPathname());

$fileInfo = next($parsedDiff);
$this->assertSame('M', $fileInfo->getStatus());
$this->assertSame('Webcreate/Vcs/Svn.php', $fileInfo->getPathname());
}
}

0 comments on commit bfcbd4a

Please sign in to comment.