Skip to content

Commit e890647

Browse files
committed
[WIP] Start implementation of proper root package patching, extend docs
1 parent 1ed71dc commit e890647

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ It's (kind-of) an alternative to two other great plugins (differences will becom
2727
| PHP Version Support confirmed by tests | 5.6+ | 5.3+ | no information |
2828
| Apply patches directly from remote locations | no (no support planned) | yes | yes |
2929
| Specify target package version constraints | yes | no | yes |
30-
| Uninstall removed patches in all cases | yes | no | TBD |
30+
| Uninstall removed patches in all cases<sup>1</sup> | yes | no | TBD |
3131
| Reapply package patches if order has changed | yes | TBD | TBD |
3232
| Choose application method (git/patch) per patch | yes | TBD | TBD |
33+
| Apply patches to root package/directory | yes | no | TBD |
34+
35+
<small>
36+
<sup>1</sup> Root package patching is the exception, please see [Applying patches to root package]() in usage docs section.
37+
</small>
3338

3439
### Some feature hilights
3540

@@ -85,6 +90,18 @@ plugins have done their work so patching source files in vendor will have no eff
8590

8691
### Define patches in your root package
8792

93+
### Applying patches to root package (root project folder)
94+
95+
Define patches as you normally would. If your root package is not named the you should use special
96+
`__root__` as package name.
97+
98+
**CAUTION** Since root package cannot be reinstalled once patches are applied they cannot be removed!
99+
This means that if you want to remove patches applied to root package you should reinstall the whole
100+
project manually. The plugin will warn you when this is the case but will not fail. It will try
101+
to apply any new root package patches though.
102+
103+
__New patches will be applied to the root package but then _application order_ is not guaranteed.__
104+
88105
### Options
89106

90107
#### Strip defined number of components when applying patch (`-pX`)

src/PatchApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class PatchApplication
3131

3232
/**
3333
* @param Patch $patch
34-
* @param PackageInterface $sourcePackage
34+
* @param PackageInterface|null $sourcePackage
3535
* @param PackageInterface $targetPackage
3636
* @param string $hash
3737
*/

src/Patcher.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ private function reinstallPackages()
254254
$localRepo = $this->repositoryManager->getLocalRepository();
255255

256256
foreach ($this->packagesToReinstall as $package) {
257+
if ($package instanceof RootPackageInterface) {
258+
$this->logger->warning(sprintf('Root package patches have changed but cannot reinstall it, will apply only new patches. You should reinstall the whole project to be safe.',
259+
$package->getName(),
260+
$package->getPrettyVersion()
261+
));
262+
263+
continue;
264+
}
265+
257266
$this->logger->notice(sprintf('Reinstalling <info>%s</info> (<comment>%s</comment>) for re-patch',
258267
$package->getName(),
259268
$package->getPrettyVersion()
@@ -293,6 +302,16 @@ private function applyPatches()
293302
}
294303
}
295304

305+
private function applyPatchesToPackage(PackagePatchApplication $packagePatchApplication)
306+
{
307+
308+
}
309+
310+
private function applyPatchesToRootPackage(PackagePatchApplication $packagePatchApplication)
311+
{
312+
313+
}
314+
296315
/**
297316
* @return PackageInterface[]
298317
*/

0 commit comments

Comments
 (0)