Skip to content

Commit 7643add

Browse files
committed
MC-37324: Add fallback to 'patch' command when 'git' command is not available
- Remove -f flag in patch command - Fix services configuration
1 parent 661c464 commit 7643add

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

config/services.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
<service id="Magento\CloudPatches\Patch\Pool\RequiredPool" lazy="true"/>
3030
<service id="Magento\CloudPatches\Patch\Pool\LocalPool" lazy="true"/>
3131
<service id="Magento\CloudPatches\Patch\Status\StatusPool" autowire="false"/>
32+
<service id="Magento\CloudPatches\Patch\PatchCommand" autowire="false"/>
33+
<service id="Magento\CloudPatches\Patch\PatchCommandInterface" alias="Magento\CloudPatches\Patch\PatchCommand"/>
3234
<service id="statusPool" class="Magento\CloudPatches\Patch\Status\StatusPool" lazy="true">
3335
<argument key="$resolvers" type="collection">
3436
<argument type="service" id="Magento\CloudPatches\Patch\Status\LocalResolver"/>
@@ -84,8 +86,5 @@
8486
<argument type="service" id="Magento\CloudPatches\Shell\Command\PatchDriver"/>
8587
</argument>
8688
</service>
87-
<service id="Magento\CloudPatches\Patch\Applier">
88-
<argument key="$patchCommand" type="service" id="patchCommand"/>
89-
</service>
9089
</services>
9190
</container>

src/Shell/Command/PatchDriver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function apply(string $patch)
3737
{
3838
try {
3939
$this->applyCheck($patch);
40-
$this->processFactory->create(['patch', '--silent', '-f', '-p1'], $patch)
40+
$this->processFactory->create(['patch', '--silent', '-p1', '--no-backup-if-mismatch'], $patch)
4141
->mustRun();
4242
} catch (ProcessFailedException $exception) {
4343
throw new PatchCommandException('Failed to apply patch', $exception->getCode(), $exception);
@@ -51,7 +51,7 @@ public function revert(string $patch)
5151
{
5252
try {
5353
$this->revertCheck($patch);
54-
$this->processFactory->create(['patch', '--silent', '-f', '-p1', '--reverse'], $patch)
54+
$this->processFactory->create(['patch', '--silent', '-p1', '--no-backup-if-mismatch', '--reverse'], $patch)
5555
->mustRun();
5656
} catch (ProcessFailedException $exception) {
5757
throw new PatchCommandException('Failed to revert patch', $exception->getCode(), $exception);
@@ -64,7 +64,7 @@ public function revert(string $patch)
6464
public function applyCheck(string $patch)
6565
{
6666
try {
67-
$this->processFactory->create(['patch', '--silent', '-f', '-p1', '--dry-run'], $patch)
67+
$this->processFactory->create(['patch', '--silent', '-p1', '--dry-run'], $patch)
6868
->mustRun();
6969
} catch (ProcessFailedException $exception) {
7070
throw new PatchCommandException('Patch cannot be applied', $exception->getCode(), $exception);
@@ -77,7 +77,7 @@ public function applyCheck(string $patch)
7777
public function revertCheck(string $patch)
7878
{
7979
try {
80-
$this->processFactory->create(['patch', '--silent', '-f', '-p1', '--reverse', '--dry-run'], $patch)
80+
$this->processFactory->create(['patch', '--silent', '-p1', '--reverse', '--dry-run'], $patch)
8181
->mustRun();
8282
} catch (ProcessFailedException $exception) {
8383
throw new PatchCommandException('Patch cannot be reverted', $exception->getCode(), $exception);

0 commit comments

Comments
 (0)