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

cweagans / composer-patches / 4121168525

pending completion
4121168525

push

github

GitHub
Merge pull request #455 from cweagans/451-dry-run

18 of 18 new or added lines in 2 files covered. (100.0%)

478 of 593 relevant lines covered (80.61%)

3.34 hits per line

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

23.81
/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
        $status = $this->executeCommand(
×
16
            '%s -p%s --posix --batch --dry-run -d %s -i %s',
×
17
            $this->patchTool(),
×
18
            $patch->depth,
×
19
            $path,
×
20
            $patch->localPath
×
21
        );
×
22
        if (!$status) {
×
23
            return false;
×
24
        }
25

26
        return $this->executeCommand(
×
27
            '%s -p%s --verbose --posix --batch -d %s -i %s',
×
28
            $this->patchTool(),
×
29
            $patch->depth,
×
30
            $path,
×
31
            $patch->localPath
×
32
        );
×
33
    }
34

35
    public function canUse(): bool
36
    {
37
        $output = "";
4✔
38
        $result = $this->executor->execute($this->patchTool() . ' --version', $output);
4✔
39
        // TODO: Is it a valid assumption to assume that if GNU is *not* in the version output, that it's BSD patch?
40
        $usable = ($result === 0) && (!str_contains($output, 'GNU patch'));
4✔
41

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

44
        return $usable;
4✔
45
    }
46
}
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

© 2026 Coveralls, Inc