Created
July 16, 2022 12:22
-
-
Save mahelbir/479a06a5142b187bda5d58668472225f to your computer and use it in GitHub Desktop.
PHP file to zip changed files (differences between working directory and staging area)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
exec("git diff --name-only --diff-filter=d", $out); | |
exec("git ls-files --others --exclude-standard", $out2); | |
if (count($out) > 0 || count($out2) > 0) { | |
$zip = new ZipArchive(); | |
$zipName = "patch-" . date("YmdHi") . ".zip"; | |
if ($zip->open($zipName, ZipArchive::CREATE)) { | |
foreach ($out as $line) { | |
if (file_exists($line)) | |
$zip->addFile($line); | |
} | |
foreach ($out2 as $line) { | |
if (file_exists($line)) | |
$zip->addFile($line); | |
} | |
$zip->close(); | |
} | |
exit("New patch: $zipName"); | |
} else { | |
exit("No patch!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage :
php patch.php