Skip to content

Commit f490f30

Browse files
author
Allan Paiste
committed
merged in changes from release/3
2 parents 7f0c448 + be43187 commit f490f30

11 files changed

+904
-48
lines changed

CHANGELOG.md

+860
Large diffs are not rendered by default.

LICENSE_VAIMO.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2009-2018 Vaimo Group.
1+
Copyright © 2009-2019 Vaimo Group.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of
44
this software and associated documentation files (the "Software"), to deal in

changelog.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"DEV.4.8.0": {
2+
"4.8.0": {
33
"overview": "all features and fixes in this release are forward-ported from 3.39.0",
44
"feature": [
55
"added --brief to list command (skips over description, etc)",
@@ -16,8 +16,7 @@
1616
"queue resolver re-introducing undo'd patches when patches targeting a package that had bundled patches defined against it",
1717
"show all applied patches when running 'redo' command without a filter (otherwise only matched patches are shown)",
1818
"hide NEW patches (that might be failing) when doing filtered redo/undo calls to avoid too much noise in output where it's pretty clear that developer is working with a sub-selection of patches (all shown when doing explicit call)",
19-
"... patch apply failure not shown correctly when failure caused by a new patch (patches targeting same area of a file; conflicting)",
20-
"... composer lock still modified when applying patches (leaves empty EXTRA key behind where there previously wasn't one present)"
19+
"composer lock still modified when applying patches (leaves empty EXTRA key behind where there previously wasn't one present)"
2120
]
2221
},
2322
"4.7.0": {
@@ -128,7 +127,7 @@
128127
"allow patch failures to be passed over gracefully with extra/patcher/graceful configuration in root package"
129128
]
130129
},
131-
"DEV.3.39.0": {
130+
"3.39.0": {
132131
"feature": [
133132
"added --brief to list command (skips over description, etc)",
134133
"when using --filter or targeting a specific package with 'redo', 'undo' or 'apply', show only those patches that match with the filter; other patches still applied, just not reported (all actions can still be made visible when using --explicit flag)",
@@ -144,8 +143,7 @@
144143
"queue resolver re-introducing undo'd patches when patches targeting a package that had bundled patches defined against it",
145144
"show all applied patches when running 'redo' command without a filter (otherwise only matched patches are shown)",
146145
"hide NEW patches (that might be failing) when doing filtered redo/undo calls to avoid too much noise in output where it's pretty clear that developer is working with a sub-selection of patches (all shown when doing explicit call)",
147-
"... patch apply failure not shown correctly when failure caused by a new patch (patches targeting same area of a file; conflicting)",
148-
"... composer lock still modified when applying patches (leaves empty EXTRA key behind where there previously wasn't one present)"
146+
"composer lock still modified when applying patches (leaves empty EXTRA key behind where there previously wasn't one present)"
149147
],
150148
"branch": "release/3"
151149
},

composer.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"marcj/topsort": "^1.0"
1717
},
1818
"require-dev": {
19-
"vaimo/composer-changelogs": "^0.6.2"
19+
"vaimo/composer-changelogs": "^0.13.1"
2020
},
2121
"support": {
2222
"source": "https://github.com/vaimo/composer-patches",
@@ -71,7 +71,10 @@
7171
"class": "Vaimo\\ComposerPatches\\Plugin",
7272
"patcher_plugin": true,
7373
"changelog": {
74-
"source": "changelog.json"
74+
"source": "changelog.json",
75+
"output": {
76+
"md": "CHANGELOG.md"
77+
}
7578
}
7679
},
7780
"autoload": {

src/Bootstrap.php

+21-13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Vaimo\ComposerPatches\Composer\ConfigKeys as Config;
99
use Vaimo\ComposerPatches\Config as PluginConfig;
1010
use Vaimo\ComposerPatches\Factories;
11+
use Vaimo\ComposerPatches\Composer\Constraint;
1112

1213
class Bootstrap
1314
{
@@ -136,26 +137,33 @@ private function applyPatchesWithConfig(PluginConfig $config, $devMode = false)
136137

137138
public function sanitizeLocker()
138139
{
139-
if (!$lock = $this->lockerManager->readLockData()) {
140+
if (!$lockData = $this->lockerManager->readLockData()) {
140141
return;
141142
}
142-
143-
$lockBefore = serialize($lock);
144143

145-
$nodes = $this->dataUtils->getNodeReferencesByPaths($lock, array(
146-
implode('/', array(Config::PACKAGES, '*', Config::CONFIG_ROOT)),
147-
implode('/', array(Config::PACKAGES_DEV, '*', Config::CONFIG_ROOT))
148-
));
144+
$queriedPaths = array(
145+
implode('/', array(Config::PACKAGES, Constraint::ANY)),
146+
implode('/', array(Config::PACKAGES_DEV, Constraint::ANY))
147+
);
148+
149+
$nodes = $this->dataUtils->getNodeReferencesByPaths($lockData, $queriedPaths);
149150

150151
foreach ($nodes as &$node) {
151-
unset($node[PluginConfig::APPLIED_FLAG]);
152-
unset($node);
152+
if (!isset($node[Config::CONFIG_ROOT][PluginConfig::APPLIED_FLAG])) {
153+
continue;
154+
}
155+
156+
unset($node[Config::CONFIG_ROOT][PluginConfig::APPLIED_FLAG]);
157+
158+
if ($node[Config::CONFIG_ROOT]) {
159+
continue;
160+
}
161+
162+
unset($node[Config::CONFIG_ROOT]);
153163
}
154164

155-
if (serialize($lock) === $lockBefore) {
156-
return;
157-
}
165+
unset($node);
158166

159-
$this->lockerManager->writeLockData($lock);
167+
$this->lockerManager->writeLockData($lockData);
160168
}
161169
}

src/Factories/PatchesApplierFactory.php

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ public function create(PluginConfig $pluginConfig, ListResolver $listResolver, O
111111
$packagePatchApplier,
112112
$queueGenerator,
113113
$patcherStateManager,
114-
$repositoryStateAnalyser,
115114
$patchInfoLogger,
116115
$outputStrategy,
117116
$this->logger

src/Managers/LockerManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private function getLockFile()
4848
$composerFile = \Composer\Factory::getComposerFile();
4949

5050
$lockFile = 'json' === pathinfo($composerFile, PATHINFO_EXTENSION)
51-
? substr($composerFile, 0, -4).'lock'
51+
? substr($composerFile, 0, -4) . 'lock'
5252
: $composerFile . '.lock';
5353

5454
return new \Composer\Json\JsonFile($lockFile, null, $this->io);

src/Plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Plugin implements \Composer\Plugin\PluginInterface,
2626
/**
2727
* @var \Vaimo\ComposerPatches\Bootstrap
2828
*/
29-
private $bootstrap;
29+
private $bootstrap;
3030

3131
public function activate(\Composer\Composer $composer, \Composer\IO\IOInterface $io)
3232
{

src/Repository/PatchesApplier.php

+1-15
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ class PatchesApplier
3636
*/
3737
private $patcherStateManager;
3838

39-
/**
40-
* @var \Vaimo\ComposerPatches\Repository\State\Analyser
41-
*/
42-
private $repositoryStateAnalyser;
43-
4439
/**
4540
* @var \Vaimo\ComposerPatches\Repository\StateGenerator
4641
*/
@@ -70,19 +65,13 @@ class PatchesApplier
7065
* \Vaimo\ComposerPatches\Utils\PatchListUtils
7166
*/
7267
private $patchListUtils;
73-
74-
/**
75-
* @var \Vaimo\ComposerPatches\Utils\PackageListUtils
76-
*/
77-
private $packageListUtils;
78-
68+
7969
/**
8070
* @param \Vaimo\ComposerPatches\Package\Collector $packageCollector
8171
* @param \Vaimo\ComposerPatches\Managers\RepositoryManager $repositoryManager
8272
* @param \Vaimo\ComposerPatches\Package\PatchApplier $patchApplier
8373
* @param \Vaimo\ComposerPatches\Repository\PatchesApplier\QueueGenerator $queueGenerator
8474
* @param \Vaimo\ComposerPatches\Managers\PatcherStateManager $patcherStateManager
85-
* @param \Vaimo\ComposerPatches\Repository\State\Analyser $repositoryStateAnalyser
8675
* @param \Vaimo\ComposerPatches\Package\PatchApplier\InfoLogger $patchInfoLogger
8776
* @param \Vaimo\ComposerPatches\Strategies\OutputStrategy $outputStrategy
8877
* @param \Vaimo\ComposerPatches\Logger $logger
@@ -93,7 +82,6 @@ public function __construct(
9382
\Vaimo\ComposerPatches\Package\PatchApplier $patchApplier,
9483
\Vaimo\ComposerPatches\Repository\PatchesApplier\QueueGenerator $queueGenerator,
9584
\Vaimo\ComposerPatches\Managers\PatcherStateManager $patcherStateManager,
96-
\Vaimo\ComposerPatches\Repository\State\Analyser $repositoryStateAnalyser,
9785
\Vaimo\ComposerPatches\Package\PatchApplier\InfoLogger $patchInfoLogger,
9886
\Vaimo\ComposerPatches\Strategies\OutputStrategy $outputStrategy,
9987
\Vaimo\ComposerPatches\Logger $logger
@@ -103,7 +91,6 @@ public function __construct(
10391
$this->packagePatchApplier = $patchApplier;
10492
$this->queueGenerator = $queueGenerator;
10593
$this->patcherStateManager = $patcherStateManager;
106-
$this->repositoryStateAnalyser = $repositoryStateAnalyser;
10794
$this->patchInfoLogger = $patchInfoLogger;
10895
$this->logger = $logger;
10996

@@ -115,7 +102,6 @@ public function __construct(
115102

116103
$this->packageUtils = new \Vaimo\ComposerPatches\Utils\PackageUtils();
117104
$this->patchListUtils = new \Vaimo\ComposerPatches\Utils\PatchListUtils();
118-
$this->packageListUtils = new \Vaimo\ComposerPatches\Utils\PackageListUtils();
119105
}
120106

121107
public function apply(Repository $repository, array $patches)

src/Strategies/Package/DefaultResetStrategy.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Composer\Downloader\VcsCapableDownloaderInterface as VcsCapable;
99
use Composer\Downloader\ChangeReportInterface as ChangeReportCapable;
10+
use Composer\Downloader\PathDownloader;
1011

1112
class DefaultResetStrategy implements \Vaimo\ComposerPatches\Interfaces\PackageResetStrategyInterface
1213
{
@@ -36,7 +37,10 @@ public function shouldAllowReset(\Composer\Package\PackageInterface $package)
3637
{
3738
$downloader = $this->downloader->getDownloaderForInstalledPackage($package);
3839

39-
if ($downloader instanceof ChangeReportCapable && $downloader instanceof VcsCapable) {
40+
if ($downloader instanceof ChangeReportCapable
41+
&& $downloader instanceof VcsCapable
42+
&& !$downloader instanceof PathDownloader
43+
) {
4044
$installPath = $this->installer->getInstallPath($package);
4145

4246
return !(bool)$downloader->getLocalChanges($package, $installPath);

src/Utils/DataUtils.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ public function getNodeReferencesByPaths(array &$data, array $paths)
5353
foreach ($item[0] as &$node) {
5454
if ($segment === null) {
5555
$result[] = &$node;
56-
} else {
57-
if ($segment === '*') {
58-
$stack[] = array(&$node, $item[1]);
59-
} else if (isset($node[$segment])) {
60-
$stack[] = array(array(&$node[$segment]), $item[1]);
61-
}
56+
} else if ($segment === '*') {
57+
$stack[] = array(&$node, $item[1]);
58+
} else if (isset($node[$segment])) {
59+
$stack[] = array(array(&$node[$segment]), $item[1]);
6260
}
63-
61+
6462
unset($node);
6563
}
6664
}

0 commit comments

Comments
 (0)