Skip to content

Commit

Permalink
Make compatible with Composer 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
francoispluchino committed Jan 18, 2017
1 parent eb373c7 commit ee87499
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 117 deletions.
10 changes: 0 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,14 @@ matrix:
include:
- php: 5.5
env: COMPOSER_VERSION=""
- php: 5.5
env: COMPOSER_VERSION="1.2.x-dev"
- php: 5.6
env: COMPOSER_VERSION=""
- php: 5.6
env: COMPOSER_VERSION="1.2.x-dev"
- php: 7.0
env: COMPOSER_VERSION=""
- php: 7.0
env: COMPOSER_VERSION="1.2.x-dev"
- php: hhvm
env: COMPOSER_VERSION=""
- php: hhvm
env: COMPOSER_VERSION="1.2.x-dev"
- php: nightly
env: COMPOSER_VERSION=""
- php: nightly
env: COMPOSER_VERSION="1.2.x-dev"

allow_failures:
- php: nightly
Expand Down
15 changes: 15 additions & 0 deletions Tests/Fixtures/Repository/Vcs/MockVcsDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,19 @@ protected function getContents()
{
return $this->contents;
}

/**
* {@inheritdoc}
*/
public function getFileContent($file, $identifier)
{
}

/**
* {@inheritdoc}
*/
public function getChangeDate($identifier)
{
return new \DateTime();
}
}
4 changes: 2 additions & 2 deletions Tests/Util/PerforceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function ($command, &$output) {

$result = $this->perforce->getComposerInformation('//depot/branch@0.0.1');

$this->assertSame('', $result);
$this->assertNull($result);
}

public function testGetComposerInformationWithLabelWithStreamWithNoChange()
Expand All @@ -263,7 +263,7 @@ function ($command, &$output) {

$result = $this->perforce->getComposerInformation('//depot/branch@0.0.1');

$this->assertSame('', $result);
$this->assertNull($result);
}

public function testCheckServerExists()
Expand Down
42 changes: 4 additions & 38 deletions Util/Perforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,45 +44,11 @@ public function initialize($repoConfig)
*/
public function getComposerInformation($identifier)
{
$index = strpos($identifier, '@');
$composerFileContent = $this->getFileContent($this->filename, $identifier);

if ($index === false) {
$composerJson = $identifier.'/'.$this->filename;

return $this->getComposerInformationFromPath($composerJson);
}

return $this->getComposerInformationFromLabel($identifier, $index);
}

/**
* @param string $identifier
* @param string $index
*
* @return array|string
*/
public function getComposerInformationFromLabel($identifier, $index)
{
$composerJsonPath = substr($identifier, 0, $index).'/'.$this->filename.substr($identifier, $index);
$command = $this->generateP4Command(' files '.$composerJsonPath, false);
$this->executeCommand($command);
$result = $this->commandResult;
$index2 = strpos($result, 'no such file(s).');

if ($index2 === false) {
$index3 = strpos($result, 'change');

if (!($index3 === false)) {
$phrase = trim(substr($result, $index3));
$fields = explode(' ', $phrase);
$id = $fields[1];
$composerJson = substr($identifier, 0, $index).'/'.$this->filename.'@'.$id;

return $this->getComposerInformationFromPath($composerJson);
}
}

return '';
return !$composerFileContent
? null
: json_decode($composerFileContent, true);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"composer-plugin-api": "^1.0"
},
"require-dev": {
"composer/composer": "^1.0.0"
"composer/composer": "^1.3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -32,7 +32,7 @@
"extra": {
"class": "Fxp\\Composer\\AssetPlugin\\FxpAssetPlugin",
"branch-alias": {
"dev-master": "1.2-dev"
"dev-master": "1.3-dev"
}
}
}
Loading

0 comments on commit ee87499

Please sign in to comment.