Skip to content

Commit 24cdf11

Browse files
committed
MC-36033: Split ece-patches and magento-patches application
- fixes after CR
1 parent 008df20 commit 24cdf11

19 files changed

+179
-88
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
"symfony/process": "^2.1||^4.1",
1616
"symfony/proxy-manager-bridge": "^3.3||^4.3",
1717
"symfony/yaml": "^3.3||^4.0",
18-
"monolog/monolog": "^1.16",
19-
"magento/quality-patches": "^1.0.0"
18+
"monolog/monolog": "^1.16"
19+
},
20+
"suggest": {
21+
"magento/quality-patches": "Need to retrieve Magento quality patches"
2022
},
2123
"require-dev": {
2224
"codeception/codeception": "^2.5.3",

config/services.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<service id="Psr\Log\LoggerInterface" alias="Magento\CloudPatches\App\Logger" />
1010
<service id="Magento\CloudPatches\App\Container" autowire="false"/>
1111
<service id="Magento\CloudPatches\Filesystem\DirectoryList" autowire="false"/>
12-
<service id="Magento\QualityPatches\Info"/>
1312
<service id="Symfony\Component\Console\Helper\QuestionHelper"/>
1413
<service id="Composer\Composer"/>
1514
<service id="Magento\CloudPatches\App\GenericException" autowire="false"/>
@@ -37,7 +36,7 @@
3736
<service id="Magento\CloudPatches\Command\Process\ShowStatus">
3837
<argument key="$statusPool" type="service" id="statusPool"/>
3938
</service>
40-
<service id="Magento\CloudPatches\Command\Process\RevertEce">
39+
<service id="Magento\CloudPatches\Command\Process\Ece\Revert">
4140
<argument key="$statusPool" type="service" id="statusPool"/>
4241
</service>
4342
<service id="Magento\CloudPatches\Command\Process\Action\ApplyOptionalAction">
@@ -73,7 +72,7 @@
7372
<service id="Magento\CloudPatches\Command\Process\ApplyOptional">
7473
<argument key="$actionPool" type="service" id="ApplyOptionalActionPool"/>
7574
</service>
76-
<service id="Magento\CloudPatches\Command\Process\ApplyOptionalEce">
75+
<service id="Magento\CloudPatches\Command\Process\Ece\ApplyOptional">
7776
<argument key="$actionPool" type="service" id="ApplyOptionalActionPool"/>
7877
</service>
7978
<service id="Magento\CloudPatches\Patch\PatchBuilder" shared="false"/>

src/ApplicationEce.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function __construct(ContainerInterface $container)
4040
protected function getDefaultCommands()
4141
{
4242
return array_merge(parent::getDefaultCommands(), [
43-
$this->container->get(Command\ApplyEce::class),
44-
$this->container->get(Command\RevertEce::class),
43+
$this->container->get(Command\Ece\Apply::class),
44+
$this->container->get(Command\Ece\Revert::class),
4545
$this->container->get(Command\Status::class)
4646
]);
4747
}

src/Command/Apply.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Apply extends AbstractCommand
2828
/**
2929
* List of patches to apply.
3030
*/
31-
const ARG_LIST_OF_PATCHES = 'list_of_patches';
31+
const ARG_LIST_OF_PATCHES = 'list-of-patches';
3232

3333
/**
3434
* @var ApplyOptional

src/Command/ApplyEce.php renamed to src/Command/Ece/Apply.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\CloudPatches\Command;
8+
namespace Magento\CloudPatches\Command\Ece;
99

1010
use Magento\CloudPatches\App\RuntimeException;
11+
use Magento\CloudPatches\Command\AbstractCommand;
1112
use Magento\CloudPatches\Command\Process\ApplyLocal;
12-
use Magento\CloudPatches\Command\Process\ApplyOptionalEce;
13+
use Magento\CloudPatches\Command\Process\Ece\ApplyOptional;
1314
use Magento\CloudPatches\Command\Process\ApplyRequired;
1415
use Magento\CloudPatches\Composer\MagentoVersion;
1516
use Psr\Log\LoggerInterface;
@@ -19,17 +20,17 @@
1920
/**
2021
* Patch apply command (Cloud).
2122
*/
22-
class ApplyEce extends AbstractCommand
23+
class Apply extends AbstractCommand
2324
{
2425
/**
2526
* Command name.
2627
*/
2728
const NAME = 'apply';
2829

2930
/**
30-
* @var ApplyOptionalEce
31+
* @var ApplyOptional
3132
*/
32-
private $applyOptionalEce;
33+
private $applyOptional;
3334

3435
/**
3536
* @var ApplyRequired
@@ -53,20 +54,20 @@ class ApplyEce extends AbstractCommand
5354

5455
/**
5556
* @param ApplyRequired $applyRequired
56-
* @param ApplyOptionalEce $applyOptionalEce
57+
* @param ApplyOptional $applyOptional
5758
* @param ApplyLocal $applyLocal
5859
* @param LoggerInterface $logger
5960
* @param MagentoVersion $magentoVersion
6061
*/
6162
public function __construct(
6263
ApplyRequired $applyRequired,
63-
ApplyOptionalEce $applyOptionalEce,
64+
ApplyOptional $applyOptional,
6465
ApplyLocal $applyLocal,
6566
LoggerInterface $logger,
6667
MagentoVersion $magentoVersion
6768
) {
6869
$this->applyRequired = $applyRequired;
69-
$this->applyOptionalEce = $applyOptionalEce;
70+
$this->applyOptional = $applyOptional;
7071
$this->applyLocal = $applyLocal;
7172
$this->logger = $logger;
7273
$this->magentoVersion = $magentoVersion;
@@ -94,7 +95,7 @@ public function execute(InputInterface $input, OutputInterface $output)
9495

9596
try {
9697
$this->applyRequired->run($input, $output);
97-
$this->applyOptionalEce->run($input, $output);
98+
$this->applyOptional->run($input, $output);
9899
$this->applyLocal->run($input, $output);
99100
} catch (RuntimeException $e) {
100101
$output->writeln('<error>' . $e->getMessage() . '</error>');

src/Command/RevertEce.php renamed to src/Command/Ece/Revert.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\CloudPatches\Command;
8+
namespace Magento\CloudPatches\Command\Ece;
99

1010
use Magento\CloudPatches\App\RuntimeException;
11-
use Magento\CloudPatches\Command\Process\RevertEce as RevertEceProcess;
11+
use Magento\CloudPatches\Command\AbstractCommand;
12+
use Magento\CloudPatches\Command\Process\Ece\Revert as RevertProcess;
1213
use Magento\CloudPatches\Composer\MagentoVersion;
1314
use Psr\Log\LoggerInterface;
1415
use Symfony\Component\Console\Input\InputInterface;
@@ -17,17 +18,17 @@
1718
/**
1819
* Patch revert command (Cloud).
1920
*/
20-
class RevertEce extends AbstractCommand
21+
class Revert extends AbstractCommand
2122
{
2223
/**
2324
* Command name.
2425
*/
2526
const NAME = 'revert';
2627

2728
/**
28-
* @var RevertEceProcess
29+
* @var RevertProcess
2930
*/
30-
private $revertEce;
31+
private $revert;
3132

3233
/**
3334
* @var LoggerInterface
@@ -40,16 +41,16 @@ class RevertEce extends AbstractCommand
4041
private $magentoVersion;
4142

4243
/**
43-
* @param RevertEceProcess $revertEce
44+
* @param RevertProcess $revert
4445
* @param LoggerInterface $logger
4546
* @param MagentoVersion $magentoVersion
4647
*/
4748
public function __construct(
48-
RevertEceProcess $revertEce,
49+
RevertProcess $revert,
4950
LoggerInterface $logger,
5051
MagentoVersion $magentoVersion
5152
) {
52-
$this->revertEce = $revertEce;
53+
$this->revert = $revert;
5354
$this->logger = $logger;
5455
$this->magentoVersion = $magentoVersion;
5556

@@ -75,7 +76,7 @@ public function execute(InputInterface $input, OutputInterface $output)
7576
$this->logger->notice($this->magentoVersion->get());
7677

7778
try {
78-
$this->revertEce->run($input, $output);
79+
$this->revert->run($input, $output);
7980
} catch (RuntimeException $e) {
8081
$output->writeln('<error>' . $e->getMessage() . '</error>');
8182
$this->logger->error($e->getMessage());

src/Command/Process/ApplyLocal.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function run(InputInterface $input, OutputInterface $output)
8989
$this->printInfo($output, $message);
9090
array_push($appliedPatches, $patch);
9191
} catch (ApplierException $exception) {
92-
$this->printInfo($output, 'Error: patch conflict happened');
92+
$this->printError($output, 'Error: patch conflict happened');
9393
$messages = $this->rollbackProcessor->process($appliedPatches);
9494
$output->writeln($messages);
9595
$errorMessage = sprintf(
@@ -116,4 +116,16 @@ private function printInfo(OutputInterface $output, string $message)
116116
$output->writeln('<info>' . $message . '</info>');
117117
$this->logger->info($message);
118118
}
119+
120+
/**
121+
* Prints and logs error message.
122+
*
123+
* @param OutputInterface $output
124+
* @param string $message
125+
*/
126+
private function printError(OutputInterface $output, string $message)
127+
{
128+
$output->writeln('<error>' . $message . '</error>');
129+
$this->logger->error($message);
130+
}
119131
}

src/Command/Process/ApplyOptionalEce.php renamed to src/Command/Process/Ece/ApplyOptional.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\CloudPatches\Command\Process;
8+
namespace Magento\CloudPatches\Command\Process\Ece;
99

1010
use Magento\CloudPatches\Command\Process\Action\ActionPool;
11+
use Magento\CloudPatches\Command\Process\ProcessInterface;
1112
use Magento\CloudPatches\Environment\Config;
1213
use Magento\CloudPatches\Patch\FilterFactory;
1314
use Psr\Log\LoggerInterface;
@@ -17,7 +18,7 @@
1718
/**
1819
* Applies optional patches (Cloud).
1920
*/
20-
class ApplyOptionalEce implements ProcessInterface
21+
class ApplyOptional implements ProcessInterface
2122
{
2223
/**
2324
* @var FilterFactory

src/Command/Process/RevertEce.php renamed to src/Command/Process/Ece/Revert.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\CloudPatches\Command\Process;
8+
namespace Magento\CloudPatches\Command\Process\Ece;
99

1010
use Magento\CloudPatches\App\RuntimeException;
1111
use Magento\CloudPatches\Command\Process\Action\RevertAction;
12+
use Magento\CloudPatches\Command\Process\ProcessInterface;
13+
use Magento\CloudPatches\Command\Process\Renderer;
1214
use Magento\CloudPatches\Patch\Applier;
1315
use Magento\CloudPatches\Patch\ApplierException;
1416
use Magento\CloudPatches\Patch\Pool\LocalPool;
@@ -20,7 +22,7 @@
2022
/**
2123
* Reverts all patches (Cloud).
2224
*/
23-
class RevertEce implements ProcessInterface
25+
class Revert implements ProcessInterface
2426
{
2527
/**
2628
* @var RevertAction
@@ -53,7 +55,7 @@ class RevertEce implements ProcessInterface
5355
private $statusPool;
5456

5557
/**
56-
* @param Action\RevertAction $revertAction
58+
* @param RevertAction $revertAction
5759
* @param LoggerInterface $logger
5860
* @param Applier $applier
5961
* @param LocalPool $localPool

src/Command/Revert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Revert extends AbstractCommand
2929
/**
3030
* List of patches to revert.
3131
*/
32-
const ARG_LIST_OF_PATCHES = 'list_of_patches';
32+
const ARG_LIST_OF_PATCHES = 'list-of-patches';
3333

3434
/**
3535
* Revert all patches.

src/Composer/QualityPackage.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches\Composer;
9+
10+
/**
11+
* Provides info from magento/quality-patches package.
12+
*/
13+
class QualityPackage
14+
{
15+
/**
16+
* @var string|null
17+
*/
18+
private $patchesDirectory;
19+
20+
/**
21+
* @var string|null
22+
*/
23+
private $patchesConfig;
24+
25+
/**
26+
* QualityPackage constructor
27+
*/
28+
public function __construct()
29+
{
30+
if (class_exists(\Magento\QualityPatches\Info::class)) {
31+
$info = new \Magento\QualityPatches\Info();
32+
$this->patchesDirectory = $info->getPatchesDirectory();
33+
$this->patchesConfig = $info->getPatchesConfig();
34+
}
35+
}
36+
37+
/**
38+
* Returns path to patches directory.
39+
*
40+
* @return string|null
41+
*/
42+
public function getPatchesDirectory()
43+
{
44+
return $this->patchesDirectory;
45+
}
46+
47+
/**
48+
* Returns path to patches configuration file.
49+
*
50+
* @return string|null
51+
*/
52+
public function getPatchesConfig()
53+
{
54+
return $this->patchesConfig;
55+
}
56+
}

src/Patch/Collector/QualityCollector.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
namespace Magento\CloudPatches\Patch\Collector;
99

10+
use Magento\CloudPatches\Composer\QualityPackage;
1011
use Magento\CloudPatches\Patch\Data\PatchInterface;
1112
use Magento\CloudPatches\Composer\Package;
1213
use Magento\CloudPatches\Patch\PatchBuilder;
1314
use Magento\CloudPatches\Patch\PatchIntegrityException;
1415
use Magento\CloudPatches\Patch\SourceProvider;
1516
use Magento\CloudPatches\Patch\SourceProviderException;
16-
use Magento\QualityPatches\Info as QualityPatchesInfo;
1717

1818
/**
1919
* Collects patches.
@@ -59,9 +59,9 @@ class QualityCollector
5959
private $package;
6060

6161
/**
62-
* @var QualityPatchesInfo
62+
* @var QualityPackage
6363
*/
64-
private $qualityPatchesInfo;
64+
private $qualityPackage;
6565

6666
/**
6767
* @var array|null
@@ -76,18 +76,18 @@ class QualityCollector
7676
/**
7777
* @param SourceProvider $sourceProvider
7878
* @param Package $package
79-
* @param QualityPatchesInfo $qualityPatchesInfo
79+
* @param QualityPackage $qualityPackage
8080
* @param PatchBuilder $patchBuilder
8181
*/
8282
public function __construct(
8383
SourceProvider $sourceProvider,
8484
Package $package,
85-
QualityPatchesInfo $qualityPatchesInfo,
85+
QualityPackage $qualityPackage,
8686
PatchBuilder $patchBuilder
8787
) {
8888
$this->sourceProvider = $sourceProvider;
8989
$this->package = $package;
90-
$this->qualityPatchesInfo = $qualityPatchesInfo;
90+
$this->qualityPackage = $qualityPackage;
9191
$this->patchBuilder = $patchBuilder;
9292
}
9393

@@ -204,7 +204,7 @@ private function createPatch(
204204
bool $patchDeprecated
205205
): PatchInterface {
206206
try {
207-
$patchPath = $this->qualityPatchesInfo->getPatchesDirectory() . '/' . $patchFile;
207+
$patchPath = $this->qualityPackage->getPatchesDirectory() . '/' . $patchFile;
208208
$this->patchBuilder->setId($patchId);
209209
$this->patchBuilder->setTitle($patchTitle);
210210
$this->patchBuilder->setFilename($patchFile);

0 commit comments

Comments
 (0)