mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-08 20:22:24 +00:00
Updated Rector to commit 3f3c8933fc
47704638c5
add geneate changelog to rector.php3f3c8933fc
fix issue message duplicationg in generate-chnagelog
This commit is contained in:
parent
d7d4659aca
commit
5becefa64b
|
@ -4,10 +4,13 @@ declare (strict_types=1);
|
|||
namespace RectorPrefix20211115;
|
||||
|
||||
use RectorPrefix20211115\Httpful\Request;
|
||||
use RectorPrefix20211115\Nette\Utils\Strings;
|
||||
use RectorPrefix20211115\Symfony\Component\Console\Application;
|
||||
use RectorPrefix20211115\Symfony\Component\Console\Command\Command;
|
||||
use RectorPrefix20211115\Symfony\Component\Console\Input\InputArgument;
|
||||
use RectorPrefix20211115\Symfony\Component\Console\Input\InputInterface;
|
||||
use RectorPrefix20211115\Symfony\Component\Console\Output\OutputInterface;
|
||||
use RectorPrefix20211115\Symfony\Component\Process\Process;
|
||||
use RectorPrefix20211115\Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
/**
|
||||
|
@ -27,6 +30,10 @@ final class GenerateChangelogCommand extends \RectorPrefix20211115\Symfony\Compo
|
|||
* @var string
|
||||
*/
|
||||
private const DEVELOPMENT_REPOSITORY_NAME = 'rectorphp/rector-src';
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private const EXCLUDED_THANKS_NAMES = ['TomasVotruba'];
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -35,6 +42,10 @@ final class GenerateChangelogCommand extends \RectorPrefix20211115\Symfony\Compo
|
|||
* @var string
|
||||
*/
|
||||
private const OPTION_TO_COMMIT = 'to-commit';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const HASH = 'hash';
|
||||
protected function configure() : void
|
||||
{
|
||||
$this->setName(\RectorPrefix20211115\Symplify\PackageBuilder\Console\Command\CommandNaming::classToName(self::class));
|
||||
|
@ -47,22 +58,23 @@ final class GenerateChangelogCommand extends \RectorPrefix20211115\Symfony\Compo
|
|||
*/
|
||||
protected function execute($input, $output) : int
|
||||
{
|
||||
$commitHashRange = \sprintf('%s..%s', $input->getArgument(self::OPTION_FROM_COMMIT), $input->getArgument(self::OPTION_TO_COMMIT));
|
||||
$commitLines = $this->exec(['git', 'log', $commitHashRange, '--reverse', '--pretty=%H %s']);
|
||||
$fromCommit = (string) $input->getArgument(self::OPTION_FROM_COMMIT);
|
||||
$toCommit = (string) $input->getArgument(self::OPTION_TO_COMMIT);
|
||||
$commitLines = $this->resolveCommitLinesFromToHashes($fromCommit, $toCommit);
|
||||
$commits = \array_map(function (string $line) : array {
|
||||
[$hash, $message] = \explode(' ', $line, 2);
|
||||
return ['hash' => $hash, 'message' => $message];
|
||||
}, \explode("\n", $commitLines));
|
||||
return [self::HASH => $hash, 'message' => $message];
|
||||
}, $commitLines);
|
||||
$i = 0;
|
||||
foreach ($commits as $commit) {
|
||||
$searchPullRequestsUri = \sprintf('https://api.github.com/search/issues?q=repo:' . self::DEVELOPMENT_REPOSITORY_NAME . '+%s', $commit['hash']);
|
||||
$searchPullRequestsUri = \sprintf('https://api.github.com/search/issues?q=repo:' . self::DEVELOPMENT_REPOSITORY_NAME . '+%s', $commit[self::HASH]);
|
||||
$searchPullRequestsResponse = \RectorPrefix20211115\Httpful\Request::get($searchPullRequestsUri)->sendsAndExpectsType('application/json')->basicAuth('tomasvotruba', \getenv('GITHUB_TOKEN'))->send();
|
||||
if ($searchPullRequestsResponse->code !== 200) {
|
||||
$output->writeln(\var_export($searchPullRequestsResponse->body, \true));
|
||||
throw new \InvalidArgumentException((string) $searchPullRequestsResponse->code);
|
||||
}
|
||||
$searchPullRequestsResponse = $searchPullRequestsResponse->body;
|
||||
$searchIssuesUri = \sprintf('https://api.github.com/search/issues?q=repo:' . self::DEPLOY_REPOSITORY_NAME . '+%s', $commit['hash']);
|
||||
$searchIssuesUri = \sprintf('https://api.github.com/search/issues?q=repo:' . self::DEPLOY_REPOSITORY_NAME . '+%s', $commit[self::HASH]);
|
||||
$searchIssuesResponse = \RectorPrefix20211115\Httpful\Request::get($searchIssuesUri)->sendsAndExpectsType('application/json')->basicAuth('tomasvotruba', \getenv('GITHUB_TOKEN'))->send();
|
||||
if ($searchIssuesResponse->code !== 200) {
|
||||
$output->writeln(\var_export($searchIssuesResponse->body, \true));
|
||||
|
@ -70,18 +82,23 @@ final class GenerateChangelogCommand extends \RectorPrefix20211115\Symfony\Compo
|
|||
}
|
||||
$searchIssuesResponse = $searchIssuesResponse->body;
|
||||
$items = \array_merge($searchPullRequestsResponse->items, $searchIssuesResponse->items);
|
||||
$parenthesis = 'https://github.com/' . self::DEVELOPMENT_REPOSITORY_NAME . '/commit/' . $commit['hash'];
|
||||
$parenthesis = 'https://github.com/' . self::DEVELOPMENT_REPOSITORY_NAME . '/commit/' . $commit[self::HASH];
|
||||
$thanks = null;
|
||||
$issuesToReference = [];
|
||||
foreach ($items as $responseItem) {
|
||||
if (isset($responseItem->pull_request)) {
|
||||
$parenthesis = \sprintf('[#%d](%s)', $responseItem->number, 'https://github.com/' . self::DEVELOPMENT_REPOSITORY_NAME . '/pull/' . $responseItem->number);
|
||||
$thanks = $responseItem->user->login;
|
||||
foreach ($items as $item) {
|
||||
if (\property_exists($item, 'pull_request') && $item->pull_request !== null) {
|
||||
$parenthesis = \sprintf('[#%d](%s)', $item->number, 'https://github.com/' . self::DEVELOPMENT_REPOSITORY_NAME . '/pull/' . $item->number);
|
||||
$thanks = $item->user->login;
|
||||
} else {
|
||||
$issuesToReference[] = \sprintf('#%d', $responseItem->number);
|
||||
$issuesToReference[] = \sprintf('#%d', $item->number);
|
||||
}
|
||||
}
|
||||
$output->writeln(\sprintf('* %s (%s)%s%s', $commit['message'], $parenthesis, \count($issuesToReference) > 0 ? ', ' . \implode(', ', $issuesToReference) : '', $thanks !== null ? \sprintf(', Thanks @%s!', $thanks) : ''));
|
||||
// clean commit from duplicating issue number
|
||||
$commitMatch = \RectorPrefix20211115\Nette\Utils\Strings::match($commit['message'], '#(.*?)( \\(\\#\\d+\\))?$#ms');
|
||||
$commit = $commitMatch[1] ?? $commit['message'];
|
||||
$changelogLine = \sprintf('* %s (%s)%s%s', $commit, $parenthesis, $issuesToReference !== [] ? ', ' . \implode(', ', $issuesToReference) : '', $this->createThanks($thanks));
|
||||
$output->writeln($changelogLine);
|
||||
// not to throttle the GitHub API
|
||||
if ($i > 0 && $i % 8 === 0) {
|
||||
\sleep(60);
|
||||
}
|
||||
|
@ -89,6 +106,19 @@ final class GenerateChangelogCommand extends \RectorPrefix20211115\Symfony\Compo
|
|||
}
|
||||
return self::SUCCESS;
|
||||
}
|
||||
/**
|
||||
* @param string|null $thanks
|
||||
*/
|
||||
protected function createThanks($thanks) : string
|
||||
{
|
||||
if ($thanks === null) {
|
||||
return '';
|
||||
}
|
||||
if (\in_array($thanks, self::EXCLUDED_THANKS_NAMES, \true)) {
|
||||
return '';
|
||||
}
|
||||
return \sprintf(', Thanks @%s!', $thanks);
|
||||
}
|
||||
/**
|
||||
* @param string[] $commandParts
|
||||
*/
|
||||
|
@ -98,6 +128,17 @@ final class GenerateChangelogCommand extends \RectorPrefix20211115\Symfony\Compo
|
|||
$process->run();
|
||||
return $process->getOutput();
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveCommitLinesFromToHashes(string $fromCommit, string $toCommit) : array
|
||||
{
|
||||
$commitHashRange = \sprintf('%s..%s', $fromCommit, $toCommit);
|
||||
$output = $this->exec(['git', 'log', $commitHashRange, '--reverse', '--pretty=%H %s']);
|
||||
$commitLines = \explode("\n", $output);
|
||||
// remove empty values
|
||||
return \array_filter($commitLines);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Inspired from @see https://github.com/phpstan/phpstan-src/blob/master/bin/generate-changelog.php
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'eaf1f250031db227ef2c623c16753a3642bfa2bb';
|
||||
public const PACKAGE_VERSION = '3f3c8933fc21d42199d644665ee6767ad418dee8';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-11-15 14:45:09';
|
||||
public const RELEASE_DATE = '2021-11-15 17:10:28';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20211115\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582::getLoader();
|
||||
return ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5::getLoader();
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582
|
||||
class ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1c857d1d70d95b04b5269943edc23582::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4b75fe4307683bd2fbcb44088193d9e5::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit1c857d1d70d95b04b5269943edc23582::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit4b75fe4307683bd2fbcb44088193d9e5::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire1c857d1d70d95b04b5269943edc23582($fileIdentifier, $file);
|
||||
composerRequire4b75fe4307683bd2fbcb44088193d9e5($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire1c857d1d70d95b04b5269943edc23582($fileIdentifier, $file)
|
||||
function composerRequire4b75fe4307683bd2fbcb44088193d9e5($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1c857d1d70d95b04b5269943edc23582
|
||||
class ComposerStaticInit4b75fe4307683bd2fbcb44088193d9e5
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3545,9 +3545,9 @@ class ComposerStaticInit1c857d1d70d95b04b5269943edc23582
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1c857d1d70d95b04b5269943edc23582::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1c857d1d70d95b04b5269943edc23582::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1c857d1d70d95b04b5269943edc23582::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4b75fe4307683bd2fbcb44088193d9e5::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4b75fe4307683bd2fbcb44088193d9e5::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4b75fe4307683bd2fbcb44088193d9e5::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
|
|||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20211115\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582', false) && !interface_exists('ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582', false) && !trait_exists('ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582', false)) {
|
||||
spl_autoload_call('RectorPrefix20211115\ComposerAutoloaderInit1c857d1d70d95b04b5269943edc23582');
|
||||
if (!class_exists('ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5', false) && !interface_exists('ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5', false) && !trait_exists('ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5', false)) {
|
||||
spl_autoload_call('RectorPrefix20211115\ComposerAutoloaderInit4b75fe4307683bd2fbcb44088193d9e5');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20211115\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -3309,9 +3309,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20211115\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire1c857d1d70d95b04b5269943edc23582')) {
|
||||
function composerRequire1c857d1d70d95b04b5269943edc23582() {
|
||||
return \RectorPrefix20211115\composerRequire1c857d1d70d95b04b5269943edc23582(...func_get_args());
|
||||
if (!function_exists('composerRequire4b75fe4307683bd2fbcb44088193d9e5')) {
|
||||
function composerRequire4b75fe4307683bd2fbcb44088193d9e5() {
|
||||
return \RectorPrefix20211115\composerRequire4b75fe4307683bd2fbcb44088193d9e5(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user