Skip to content

Instantly share code, notes, and snippets.

@Tuurlijk
Created November 3, 2019 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tuurlijk/98bdb14e25ff81be3e7ab243e89cc232 to your computer and use it in GitHub Desktop.
Save Tuurlijk/98bdb14e25ff81be3e7ab243e89cc232 to your computer and use it in GitHub Desktop.
<?php
$basePath = '/home/Blah/tmp/TYPO3.CMS/typo3/sysext/core/Documentation/Changelog';
$dir = new DirectoryIterator($basePath);
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
$filename = $fileinfo->getFilename();
if (strpos($filename, '.htaccess') === 0 || strpos($filename, 'Howto') === 0) {
continue;
}
echo PHP_EOL . PHP_EOL . 'Minor : ' . $filename . PHP_EOL;
generate($filename, $basePath);
}
}
function generate($minor, $basePath)
{
$publicUrlBase = 'https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/';
$dir = new DirectoryIterator($basePath . $minor);
$minorParts = explode('.', $minor);
$major = array_shift($minorParts);
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
$filename = $fileinfo->getFilename();
$filename = substr($filename, 0, -4);
if (strpos($filename, 'Feature') === 0 || strpos($filename, 'Index') === 0) {
continue;
}
$nameParts = explode('-', $filename);
$type = array_shift($nameParts);
$issue = array_shift($nameParts);
echo PHP_EOL;
$contentArray = file($basePath . $minor . '/' . $fileinfo->getFilename());
$title = getTitle($contentArray);
$publicUrl = $publicUrlBase . $minor . '/' . $filename . '.html';
$labels = implode(',', [$major, $minor, $type]);
$message = $title . PHP_EOL. PHP_EOL . $publicUrl . PHP_EOL . implode(PHP_EOL, $contentArray);
echo 'Creating Issue : ' . $issue . PHP_EOL;
echo 'Title : ' . $title . PHP_EOL;
echo 'Labels : ' . $labels . PHP_EOL;
echo 'Public : ' . $publicUrl . PHP_EOL;
$tmpFile = tmpfile();
fwrite($tmpFile, $message);
$tmpFilePath = stream_get_meta_data($tmpFile)['uri'];
// echo 'hub issue create -l ' . $labels . ' -F ' . $tmpFilePath . PHP_EOL;
exec('hub issue create -l ' . $labels . ' -F ' . $tmpFilePath );
fclose($tmpFile);
}
}
}
function getTitle($contentArray) {
$nextLineIsTitle = false;
foreach ($contentArray as $line) {
if ($nextLineIsTitle) {
return trim($line);
}
if (strpos($line, '===============') === 0) {
$nextLineIsTitle = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment