Skip to content

Commit

Permalink
TASK: Add packagist.org repository by default
Browse files Browse the repository at this point in the history
  • Loading branch information
MCStreetguy committed Sep 9, 2019
1 parent d42b68c commit a065b61
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/ComposerJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class ComposerJson extends AbstractClass
* @var array
*/
protected $nonFeatureBranches;

/**
* @var array
*/
Expand All @@ -194,7 +194,7 @@ class ComposerJson extends AbstractClass
public function __construct(array $data = [])
{
$this->_data = $data;

// String data
$this->name = (array_key_exists('name', $data) ? $data['name'] : '');
$this->description = (array_key_exists('description', $data) ? $data['description'] : '');
Expand Down Expand Up @@ -241,7 +241,7 @@ public function __construct(array $data = [])
if (is_string($license)) {
$license = [$license];
}

$this->license = $license;
}

Expand All @@ -258,6 +258,14 @@ public function __construct(array $data = [])
$this->repositories[] = new Repository($repository);
}
}

if (!array_key_exists('repositories', $data) || (array_key_exists('packagist.org', $data['repositories']) && $data['repositories']['packagist.org'] !== false)) {

This comment has been minimized.

Copy link
@antonkomarev

antonkomarev Sep 9, 2019

Collaborator

Is it right way to check for {"packagist.org": false} repository object?

It looks like $data['repositories']['packagist.org'] !== false will check for:

repositories: {
  "packagist.org": false,
  {
    "type": "composer",
    "url": "https://example.com"
  }
}

And we need to check it for:

repositories: [
  {
    "packagist.org": false
  },
  {
    "type": "composer",
    "url": "https://example.com"
  }
]

This comment has been minimized.

Copy link
@antonkomarev

antonkomarev Sep 9, 2019

Collaborator

Thank you for the changes. I will try to test it later today.

This comment has been minimized.

Copy link
@MCStreetguy

MCStreetguy Sep 9, 2019

Author Owner

Yes you're right, I mis-read that from the docs. Will push a fix in a moment.

This comment has been minimized.

Copy link
@MCStreetguy

MCStreetguy Sep 9, 2019

Author Owner

Fixed in 04d11af

$this->repositories['packagist.org'] = new Repository([
'type' => 'composer',
'url' => 'https?://repo.packagist.org',
'allow_ssl_downgrade' => true,
]);
}
}

/**
Expand Down Expand Up @@ -569,7 +577,7 @@ public function getNonFeatureBranches()
{
return $this->nonFeatureBranches;
}

/**
* Get the whole manifest file as array.
*
Expand Down

0 comments on commit a065b61

Please sign in to comment.