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

cweagans / composer-patches / 4116908618

pending completion
4116908618

push

github

GitHub
Merge pull request #447 from cweagans/2.x-wip

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

41.67
/src/Patcher/BsdPatchPatcher.php
1
<?php
2

3
namespace cweagans\Composer\Patcher;
4

5
use Composer\Util\ProcessExecutor;
6
use cweagans\Composer\Patch;
7
use Composer\IO\IOInterface;
8

9
class BsdPatchPatcher extends PatcherBase
10
{
11
    protected string $tool = 'patch';
12

13
    public function apply(Patch $patch, string $path): bool
14
    {
15
        // TODO: Dry run first?
16

17
        return $this->executeCommand(
×
18
            '%s -p%s --posix --batch -d %s -i %s',
×
19
            $this->patchTool(),
×
20
            $patch->depth,
×
21
            $path,
×
22
            $patch->localPath
×
23
        );
×
24
    }
25

26
    public function canUse(): bool
27
    {
28
        $output = "";
4✔
29
        $result = $this->executor->execute($this->patchTool() . ' --version', $output);
4✔
30
        // TODO: Is it a valid assumption to assume that if GNU is *not* in the version output, that it's BSD patch?
31
        $usable = ($result === 0) && (!str_contains($output, 'GNU patch'));
4✔
32

33
        $this->io->write(self::class . " usable: " . ($usable ? "yes" : "no"), true, IOInterface::DEBUG);
4✔
34

35
        return $usable;
4✔
36
    }
37
}
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