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

Commit bfcbd4a

Browse files
authored
Merge pull request #11 from marcojanssen/new-filename-after-original-filename
Newer log format has new filename after original name
2 parents 3a1b0d1 + 640b8b4 commit bfcbd4a

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

src/Webcreate/Vcs/Git/Parser/CliParser.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,15 @@ public function parseDiffOutput($output, array $arguments = array())
155155

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

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

164168
$retval[] = $file;
165169
} else {

tests/Webcreate/Vcs/Git/Parser/CliParserTest.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ public function it_parses_diff_output()
2828
{
2929
$diffOutput = <<<EOT
3030
A tests/Webcreate/Vcs/Git/Parser/CliParserTest.php
31-
R Webcreate/Vcs/Svn/WorkingCopy.php
32-
R062 Webcreate/Vcs/Svn/SvnAdmin.php
31+
R Webcreate/Vcs/Svn/WorkingRename.php
32+
R062 Webcreate/Vcs/Svn/WorkingCopy.php Webcreate/Vcs/Svn/WorkingRename.php
33+
D Webcreate/Vcs/Svn/AbstractSvn.php
34+
M Webcreate/Vcs/Svn.php
35+
M001 Webcreate/Vcs/Svn.php
3336
EOT;
3437

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

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

4851
$fileInfo = next($parsedDiff);
4952
$this->assertSame('R', $fileInfo->getStatus());
50-
$this->assertSame('Webcreate/Vcs/Svn/SvnAdmin.php', $fileInfo->getPathname());
53+
$this->assertSame('Webcreate/Vcs/Svn/WorkingRename.php', $fileInfo->getPathname());
54+
55+
$fileInfo = next($parsedDiff);
56+
$this->assertSame('D', $fileInfo->getStatus());
57+
$this->assertSame('Webcreate/Vcs/Svn/AbstractSvn.php', $fileInfo->getPathname());
58+
59+
$fileInfo = next($parsedDiff);
60+
$this->assertSame('M', $fileInfo->getStatus());
61+
$this->assertSame('Webcreate/Vcs/Svn.php', $fileInfo->getPathname());
62+
63+
$fileInfo = next($parsedDiff);
64+
$this->assertSame('M', $fileInfo->getStatus());
65+
$this->assertSame('Webcreate/Vcs/Svn.php', $fileInfo->getPathname());
5166
}
5267
}

0 commit comments

Comments
 (0)