diff --git a/src/Service/Git/CherryPick/GitCherryPickParser.php b/src/Service/Git/CherryPick/GitCherryPickParser.php index 7fe65429c..5376d291d 100644 --- a/src/Service/Git/CherryPick/GitCherryPickParser.php +++ b/src/Service/Git/CherryPick/GitCherryPickParser.php @@ -13,12 +13,14 @@ public function parse(string $output): CherryPickResult return new CherryPickResult(true); } - $result = preg_match_all('/CONFLICT\s+\(\S+\):\s+(\S+)/', $output, $matches); - if ($result === false || $result === 0) { - // no conflicts found - return new CherryPickResult(false); + if (preg_match_all('/CONFLICT\s+\(\S+\):\s+\S+\s+renamed to\s+(\S+)/', $output, $matches) > 0) { + return new CherryPickResult(false, $matches[1]); } - return new CherryPickResult(false, $matches[1]); + if (preg_match_all('/CONFLICT\s+\(\S+\):\s+(\S+)/', $output, $matches) > 0) { + return new CherryPickResult(false, $matches[1]); + } + + return new CherryPickResult(false); } } diff --git a/tests/Unit/Service/Git/CherryPick/GitCherryPickParserTest.php b/tests/Unit/Service/Git/CherryPick/GitCherryPickParserTest.php index fb845f9ea..2f0013a55 100644 --- a/tests/Unit/Service/Git/CherryPick/GitCherryPickParserTest.php +++ b/tests/Unit/Service/Git/CherryPick/GitCherryPickParserTest.php @@ -27,6 +27,17 @@ public function testParseWithNoCherryPick(): void static::assertSame([], $result->conflicts); } + public function testParseWithRename(): void + { + $data = "some random text\n"; + $data .= " CONFLICT (rename/delete): src/Tests/Unit/AbstractTest.php renamed to src/Tests/Unit/AbstractTestCase.php in c61a64dc1de."; + $data .= "some random text\n"; + + $result = $this->parser->parse($data); + static::assertFalse($result->completed); + static::assertSame(['src/Tests/Unit/AbstractTestCase.php'], $result->conflicts); + } + public function testParseWithConflicts(): void { $data = "some random text\n";