Created
December 4, 2020 18:35
-
-
Save Girgias/15da993a64b8def236e311409f3281a8 to your computer and use it in GitHub Desktop.
Update EN-Revision tag for PHP Doc translations after applying a patch
This file contains 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
<?php | |
$folder = __DIR__ . '/reference/imagick/'; | |
$en_revision = 351852; | |
$files = glob($folder . '*/?*.xml.orig'); | |
foreach ($files as $fileOrig) { | |
$file = substr($fileOrig, 0, -5); | |
// Check if there is a reject file, in which case do not update revision | |
if (file_exists($file . '.rej')) { | |
continue; | |
} | |
$newFileContent = preg_replace('/EN-Revision: [0-9]{5,6}/', 'EN-Revision: ' . $en_revision, | |
file_get_contents($file), -1, $count); | |
if ($newFileContent === '' || $newFileContent === false) { | |
throw new Exception(); | |
} | |
if ($count !== 1) { | |
print 'File has count different than 1: ' . $file . \PHP_EOL; | |
} | |
file_put_contents($file, $newFileContent); | |
// Delete the .orig files | |
unlink($fileOrig); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment