• 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

95.24
/src/Patcher/GnuPatchPatcher.php
1
<?php
2

3
namespace cweagans\Composer\Patcher;
4

5
use Composer\IO\IOInterface;
6
use cweagans\Composer\Patch;
7

8
class GnuPatchPatcher extends PatcherBase
9
{
10
    protected string $tool = 'patch';
11

12
    public function apply(Patch $patch, string $path): bool
13
    {
14
        $status = $this->executeCommand(
5✔
15
            '%s -p%s --dry-run --no-backup-if-mismatch -d %s -i %s',
5✔
16
            $this->patchTool(),
5✔
17
            $patch->depth,
5✔
18
            $path,
5✔
19
            $patch->localPath
5✔
20
        );
5✔
21
        if (!$status) {
5✔
22
            return false;
×
23
        }
24

25
        return $this->executeCommand(
5✔
26
            '%s -p%s --no-backup-if-mismatch --verbose -d %s -i %s',
5✔
27
            $this->patchTool(),
5✔
28
            $patch->depth,
5✔
29
            $path,
5✔
30
            $patch->localPath
5✔
31
        );
5✔
32
    }
33

34
    public function canUse(): bool
35
    {
36
        $output = "";
4✔
37
        $result = $this->executor->execute($this->patchTool() . ' --version', $output);
4✔
38
        $usable = ($result === 0) && (str_contains($output, 'GNU patch'));
4✔
39

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

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