Skip to content

Commit 87063f9

Browse files
authored
Merge pull request #19 from IonBazan/debug
improve git error logging and fix deprecations
2 parents 7500fe0 + 8e6ad97 commit 87063f9

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

src/PackageDiff.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ private function getFileContents($path)
130130

131131
$output = array();
132132
@exec(sprintf('git show %s 2>&1', escapeshellarg($path)), $output, $exit);
133+
$outputString = implode("\n", $output);
133134

134135
if (0 !== $exit) {
135-
throw new \RuntimeException(sprintf('Could not open file %s or find it in git as %s', $originalPath, $path));
136+
throw new \RuntimeException(sprintf('Could not open file %s or find it in git as %s: %s', $originalPath, $path, $outputString));
136137
}
137138

138-
return implode("\n", $output);
139+
return $outputString;
139140
}
140141
}

src/Url/GitGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class GitGenerator implements UrlGenerator
1111
*/
1212
public function supportsPackage(PackageInterface $package)
1313
{
14-
return false !== strpos($package->getSourceUrl(), $this->getDomain());
14+
return false !== strpos((string) $package->getSourceUrl(), $this->getDomain());
1515
}
1616

1717
/**

tests/Command/DiffCommandTest.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Composer\DependencyResolver\Operation\UninstallOperation;
88
use Composer\DependencyResolver\Operation\UpdateOperation;
99
use IonBazan\ComposerDiff\Command\DiffCommand;
10+
use IonBazan\ComposerDiff\Tests\Integration\ComposerApplication;
1011
use IonBazan\ComposerDiff\Tests\TestCase;
1112
use Symfony\Component\Console\Tester\CommandTester;
1213

@@ -20,7 +21,10 @@ class DiffCommandTest extends TestCase
2021
public function testItGeneratesReportInGivenFormat($expectedOutput, array $options)
2122
{
2223
$diff = $this->getMockBuilder('IonBazan\ComposerDiff\PackageDiff')->getMock();
23-
$tester = new CommandTester(new DiffCommand($diff, array('gitlab2.org')));
24+
$application = new ComposerApplication();
25+
$command = new DiffCommand($diff, array('gitlab2.org'));
26+
$command->setApplication($application);
27+
$tester = new CommandTester($command);
2428
$diff->expects($this->once())
2529
->method('getPackageDiff')
2630
->with($this->isType('string'), $this->isType('string'), false, false)
@@ -49,7 +53,10 @@ public function testItGeneratesReportInGivenFormat($expectedOutput, array $optio
4953
public function testStrictMode($exitCode, array $prodOperations, array $devOperations)
5054
{
5155
$diff = $this->getMockBuilder('IonBazan\ComposerDiff\PackageDiff')->getMock();
52-
$tester = new CommandTester(new DiffCommand($diff, array('gitlab2.org')));
56+
$application = new ComposerApplication();
57+
$command = new DiffCommand($diff, array('gitlab2.org'));
58+
$command->setApplication($application);
59+
$tester = new CommandTester($command);
5360
$diff->expects($this->exactly(2))
5461
->method('getPackageDiff')
5562
->with($this->isType('string'), $this->isType('string'), $this->isType('boolean'), false)

tests/Integration/DiffCommandTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ class DiffCommandTest extends TestCase
2424
*/
2525
public function testCommand($expectedOutput, array $input)
2626
{
27-
$tester = new CommandTester(new DiffCommand(new PackageDiff()));
27+
$application = new ComposerApplication();
28+
$command = new DiffCommand(new PackageDiff());
29+
$command->setApplication($application);
30+
$tester = new CommandTester($command);
2831
$result = $tester->execute($input);
2932
$this->assertSame(0, $result);
3033
$this->assertSame($expectedOutput, $tester->getDisplay());

0 commit comments

Comments
 (0)