|
9 | 9 |
|
10 | 10 | use Magento\CloudPatches\App\RuntimeException; |
11 | 11 | use Magento\CloudPatches\Command\Process\Renderer; |
12 | | -use Magento\CloudPatches\Patch\Data\AggregatedPatch; |
13 | 12 | use Magento\CloudPatches\Patch\Data\AggregatedPatchInterface; |
14 | 13 | use Magento\CloudPatches\Patch\Pool\OptionalPool; |
15 | 14 | use Magento\CloudPatches\Patch\Aggregator; |
@@ -93,6 +92,13 @@ public function execute(InputInterface $input, OutputInterface $output, array $p |
93 | 92 | throw new RuntimeException($e->getMessage(), $e->getCode(), $e); |
94 | 93 | } |
95 | 94 |
|
| 95 | + $patches = array_filter( |
| 96 | + $patches, |
| 97 | + function ($patch) { |
| 98 | + return !$this->statusPool->isApplied($patch->getId()); |
| 99 | + } |
| 100 | + ); |
| 101 | + |
96 | 102 | foreach ($patches as $patch) { |
97 | 103 | $this->processDeprecation($patch, $output, $input); |
98 | 104 | $this->processReplacement($patch, $output, $input); |
@@ -144,21 +150,23 @@ function ($patchId) { |
144 | 150 | } |
145 | 151 | ); |
146 | 152 |
|
147 | | - if ($requireRevertAndReplace) { |
148 | | - $ids = implode(' ', $requireRevertAndReplace); |
149 | | - $warning = sprintf('%s should be reverted and replaced with %s', $ids, $patch->getId()); |
150 | | - $output->writeln('<info>' . $warning . '</info>'); |
151 | | - $this->logger->warning($warning); |
| 153 | + if (empty($requireRevertAndReplace)) { |
| 154 | + return; |
| 155 | + } |
152 | 156 |
|
153 | | - $question = 'Do you want to proceed with reverting?'; |
154 | | - if (!$this->renderer->printQuestion($input, $output, $question)) { |
155 | | - $errorMessage = sprintf('%s can\'t be applied without reverting %s', $patch->getId(), $ids); |
| 157 | + $ids = implode(' ', $requireRevertAndReplace); |
| 158 | + $warning = sprintf('%s should be reverted and replaced with %s', $ids, $patch->getId()); |
| 159 | + $output->writeln('<info>' . $warning . '</info>'); |
| 160 | + $this->logger->warning($warning); |
156 | 161 |
|
157 | | - throw new RuntimeException($errorMessage); |
158 | | - } |
| 162 | + $question = 'Do you want to proceed with reverting?'; |
| 163 | + if (!$this->renderer->printQuestion($input, $output, $question)) { |
| 164 | + $errorMessage = sprintf('%s can\'t be applied without reverting %s', $patch->getId(), $ids); |
159 | 165 |
|
160 | | - $this->revert->execute($input, $output, $requireRevertAndReplace); |
| 166 | + throw new RuntimeException($errorMessage); |
161 | 167 | } |
| 168 | + |
| 169 | + $this->revert->execute($input, $output, $requireRevertAndReplace); |
162 | 170 | } |
163 | 171 |
|
164 | 172 | /** |
|
0 commit comments