• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cweagans / composer-patches / 4110992550

pending completion
4110992550

Pull #447

github

GitHub
Merge eaa8ee760 into a4b573156
Pull Request #447: 2.x WIP (don't merge yet)

457 of 457 new or added lines in 28 files covered. (100.0%)

456 of 570 relevant lines covered (80.0%)

3.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Command/RepatchCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace cweagans\Composer\Command;
6

7
use Composer\DependencyResolver\Operation\UninstallOperation;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11

12
class RepatchCommand extends PatchesCommandBase
13
{
14
    protected function configure(): void
15
    {
16
        $this->setName('patches-repatch');
×
17
        $this->setDescription('Delete, re-download, and re-patch each dependency with any patches defined.');
×
18
        $this->setAliases(['prp']);
×
19
    }
20

21
    protected function execute(InputInterface $input, OutputInterface $output): int
22
    {
23
        $plugin = $this->getPatchesPluginInstance();
×
24
        if (is_null($plugin)) {
×
25
            return 1;
×
26
        }
27

28
        $plugin->loadLockedPatches();
×
29
        $patchCollection = $plugin->getPatchCollection();
×
30
        if (is_null($patchCollection)) {
×
31
            return 1;
×
32
        }
33

34
        $localRepository = $this->requireComposer()
×
35
            ->getRepositoryManager()
×
36
            ->getLocalRepository();
×
37

38
        $patched_packages = $patchCollection->getPatchedPackages();
×
39
        $packages = array_filter($localRepository->getPackages(), function ($val) use ($patched_packages) {
×
40
            return in_array($val->getName(), $patched_packages);
×
41
        });
×
42

43
        // Remove patched packages so that we can re-install/re-patch.
44
        $promises = [];
×
45
        foreach ($packages as $package) {
×
46
            $uninstallOperation = new UninstallOperation($package);
×
47
            $promises[] = $this->requireComposer()
×
48
                ->getInstallationManager()
×
49
                ->uninstall($localRepository, $uninstallOperation);
×
50
        }
51
        // Wait for uninstalls to finish.
52
        $promises = array_filter($promises);
×
53
        if (!empty($promises)) {
×
54
            $this->requireComposer()->getLoop()->wait($promises);
×
55
        }
56

57
        $input = new ArrayInput(['command' => 'install']);
×
58
        $application = $this->getApplication();
×
59
        $application->setAutoExit(false);
×
60
        $application->run($input, $output);
×
61

62
        return 0;
×
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc