Skip to content

Commit

Permalink
Merge pull request #455 from cweagans/451-dry-run
Browse files Browse the repository at this point in the history
Add --dry-run to patchers
  • Loading branch information
cweagans committed Feb 8, 2023
2 parents cd06d60 + 8541d7c commit 511b413
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Patcher/BsdPatchPatcher.php
Expand Up @@ -12,7 +12,16 @@ class BsdPatchPatcher extends PatcherBase

public function apply(Patch $patch, string $path): bool
{
// TODO: Dry run first?
$status = $this->executeCommand(
'%s -p%s --posix --batch --dry-run -d %s -i %s',
$this->patchTool(),
$patch->depth,
$path,
$patch->localPath
);
if (!$status) {
return false;
}

return $this->executeCommand(
'%s -p%s --verbose --posix --batch -d %s -i %s',
Expand Down
11 changes: 10 additions & 1 deletion src/Patcher/GnuPatchPatcher.php
Expand Up @@ -11,7 +11,16 @@ class GnuPatchPatcher extends PatcherBase

public function apply(Patch $patch, string $path): bool
{
// TODO: Dry run first?
$status = $this->executeCommand(
'%s -p%s --dry-run --no-backup-if-mismatch -d %s -i %s',
$this->patchTool(),
$patch->depth,
$path,
$patch->localPath
);
if (!$status) {
return false;
}

return $this->executeCommand(
'%s -p%s --no-backup-if-mismatch --verbose -d %s -i %s',
Expand Down

0 comments on commit 511b413

Please sign in to comment.