Skip to content

Commit 60ce53d

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

File tree

13 files changed

+72
-55
lines changed

13 files changed

+72
-55
lines changed

config/services.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<service id="Magento\CloudPatches\Command\Process\ApplyOptional">
7474
<argument key="$actionPool" type="service" id="ApplyOptionalActionPool"/>
7575
</service>
76-
<service id="Magento\CloudPatches\Command\Process\ApplyOptionalEce">
76+
<service id="Magento\CloudPatches\Command\Process\Ece\ApplyOptional">
7777
<argument key="$actionPool" type="service" id="ApplyOptionalActionPool"/>
7878
</service>
7979
<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/Test/Unit/Command/ApplyEceTest.php renamed to src/Test/Unit/Command/Ece/ApplyTest.php

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

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

1010
use Magento\CloudPatches\App\RuntimeException;
1111
use Magento\CloudPatches\Command\AbstractCommand;
12-
use Magento\CloudPatches\Command\ApplyEce;
12+
use Magento\CloudPatches\Command\Ece\Apply;
1313
use Magento\CloudPatches\Command\Process\ApplyLocal;
14-
use Magento\CloudPatches\Command\Process\ApplyOptionalEce;
14+
use Magento\CloudPatches\Command\Process\Ece\ApplyOptional;
1515
use Magento\CloudPatches\Command\Process\ApplyRequired;
1616
use Magento\CloudPatches\Composer\MagentoVersion;
1717
use PHPUnit\Framework\MockObject\MockObject;
@@ -23,10 +23,10 @@
2323
/**
2424
* @inheritDoc
2525
*/
26-
class ApplyEceTest extends TestCase
26+
class ApplyTest extends TestCase
2727
{
2828
/**
29-
* @var ApplyEce
29+
* @var Apply
3030
*/
3131
private $command;
3232

@@ -36,7 +36,7 @@ class ApplyEceTest extends TestCase
3636
private $applyLocal;
3737

3838
/**
39-
* @var ApplyOptionalEce|MockObject
39+
* @var ApplyOptional|MockObject
4040
*/
4141
private $applyOptionalEce;
4242

@@ -61,12 +61,12 @@ class ApplyEceTest extends TestCase
6161
protected function setUp()
6262
{
6363
$this->applyLocal = $this->createMock(ApplyLocal::class);
64-
$this->applyOptionalEce = $this->createMock(ApplyOptionalEce::class);
64+
$this->applyOptionalEce = $this->createMock(ApplyOptional::class);
6565
$this->applyRequired = $this->createMock(ApplyRequired::class);
6666
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
6767
$this->magentoVersion = $this->createMock(MagentoVersion::class);
6868

69-
$this->command = new ApplyEce(
69+
$this->command = new Apply(
7070
$this->applyRequired,
7171
$this->applyOptionalEce,
7272
$this->applyLocal,

src/Test/Unit/Command/RevertEceTest.php renamed to src/Test/Unit/Command/Ece/RevertTest.php

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

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

1010
use Magento\CloudPatches\App\RuntimeException;
1111
use Magento\CloudPatches\Command\AbstractCommand;
12-
use Magento\CloudPatches\Command\Process\RevertEce as RevertEceProcess;
13-
use Magento\CloudPatches\Command\RevertEce;
12+
use Magento\CloudPatches\Command\Process\Ece\Revert as RevertProcess;
13+
use Magento\CloudPatches\Command\Ece\Revert;
1414
use Magento\CloudPatches\Composer\MagentoVersion;
1515
use PHPUnit\Framework\MockObject\MockObject;
1616
use PHPUnit\Framework\TestCase;
@@ -21,15 +21,15 @@
2121
/**
2222
* @inheritDoc
2323
*/
24-
class RevertEceTest extends TestCase
24+
class RevertTest extends TestCase
2525
{
2626
/**
27-
* @var RevertEce
27+
* @var Revert
2828
*/
2929
private $command;
3030

3131
/**
32-
* @var RevertEceProcess|MockObject
32+
* @var RevertProcess|MockObject
3333
*/
3434
private $revertEce;
3535

@@ -43,13 +43,13 @@ class RevertEceTest extends TestCase
4343
*/
4444
protected function setUp()
4545
{
46-
$this->revertEce = $this->createMock(RevertEceProcess::class);
46+
$this->revertEce = $this->createMock(RevertProcess::class);
4747
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
4848

4949
/** @var MagentoVersion|MockObject $magentoVersion */
5050
$magentoVersion = $this->createMock(MagentoVersion::class);
5151

52-
$this->command = new RevertEce(
52+
$this->command = new Revert(
5353
$this->revertEce,
5454
$this->logger,
5555
$magentoVersion

src/Test/Unit/Command/Process/ApplyOptionalEceTest.php renamed to src/Test/Unit/Command/Process/Ece/ApplyOptionalTest.php

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

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

1010
use Magento\CloudPatches\App\RuntimeException;
1111
use Magento\CloudPatches\Command\Process\Action\ActionPool;
12-
use Magento\CloudPatches\Command\Process\ApplyOptionalEce;
12+
use Magento\CloudPatches\Command\Process\Ece\ApplyOptional;
1313
use Magento\CloudPatches\Environment\Config;
1414
use Magento\CloudPatches\Patch\FilterFactory;
1515
use PHPUnit\Framework\MockObject\MockObject;
@@ -21,10 +21,10 @@
2121
/**
2222
* @inheritdoc
2323
*/
24-
class ApplyOptionalEceTest extends TestCase
24+
class ApplyOptionalTest extends TestCase
2525
{
2626
/**
27-
* @var ApplyOptionalEce
27+
* @var ApplyOptional
2828
*/
2929
private $applyOptionalEce;
3030

@@ -58,7 +58,7 @@ protected function setUp()
5858
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
5959
$this->config = $this->createMock(Config::class);
6060

61-
$this->applyOptionalEce = new ApplyOptionalEce(
61+
$this->applyOptionalEce = new ApplyOptional(
6262
$this->filterFactory,
6363
$this->actionPool,
6464
$this->logger,

0 commit comments

Comments
 (0)