Skip to content

Commit

Permalink
add merge-replace config to control merging of composer replace section
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin authored and reedy committed Sep 1, 2022
1 parent 176a396 commit c89677d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ExtraPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ public function mergeInto(RootPackageInterface $root, PluginState $state)
$this->mergeRequires('require', $root, $state);

$this->mergePackageLinks('conflict', $root);
$this->mergePackageLinks('replace', $root);

if ($state->shouldMergeReplace()) {
$this->mergePackageLinks('replace', $root);
}

$this->mergePackageLinks('provide', $root);

$this->mergeSuggests($root);
Expand Down
21 changes: 21 additions & 0 deletions src/PluginState.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ class PluginState
*/
protected $mergeExtraDeep = false;

/**
* Whether to merge the replace section.
*
* @var bool $mergeReplace
*/
protected $mergeReplace = true;

/**
* Whether to merge the scripts section.
*
Expand Down Expand Up @@ -160,6 +167,7 @@ public function loadSettings()
'merge-dev' => true,
'merge-extra' => false,
'merge-extra-deep' => false,
'merge-replace' => true,
'merge-scripts' => false,
],
$extra['merge-plugin'] ?? []
Expand All @@ -175,6 +183,7 @@ public function loadSettings()
$this->mergeDev = (bool)$config['merge-dev'];
$this->mergeExtra = (bool)$config['merge-extra'];
$this->mergeExtraDeep = (bool)$config['merge-extra-deep'];
$this->mergeReplace = (bool)$config['merge-replace'];
$this->mergeScripts = (bool)$config['merge-scripts'];
}

Expand Down Expand Up @@ -386,6 +395,18 @@ public function shouldMergeExtraDeep()
return $this->mergeExtraDeep;
}

/**
* Should the replace section be merged?
*
* By default, the replace section is merged.
*
* @return bool
*/
public function shouldMergeReplace()
{
return $this->mergeReplace;
}

/**
* Should the scripts section be merged?
*
Expand Down

0 comments on commit c89677d

Please sign in to comment.