diff --git a/src/Webcreate/Vcs/Git/Parser/CliParser.php b/src/Webcreate/Vcs/Git/Parser/CliParser.php index f629697..4253265 100644 --- a/src/Webcreate/Vcs/Git/Parser/CliParser.php +++ b/src/Webcreate/Vcs/Git/Parser/CliParser.php @@ -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 { diff --git a/tests/Webcreate/Vcs/Git/Parser/CliParserTest.php b/tests/Webcreate/Vcs/Git/Parser/CliParserTest.php index 0cc2f9a..c658251 100644 --- a/tests/Webcreate/Vcs/Git/Parser/CliParserTest.php +++ b/tests/Webcreate/Vcs/Git/Parser/CliParserTest.php @@ -28,8 +28,11 @@ public function it_parses_diff_output() { $diffOutput = <<parser->parseDiffOutput( @@ -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()); } }