mirror of https://github.com/rectorphp/rector.git
42 lines
1.8 KiB
PHP
42 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Core\Application;
|
|
|
|
use DateTime;
|
|
use Rector\Core\Exception\VersionException;
|
|
use RectorPrefix20210808\Symfony\Component\Process\Process;
|
|
use RectorPrefix20210808\Symplify\PackageBuilder\Console\ShellCode;
|
|
/**
|
|
* Inspired by https://github.com/composer/composer/blob/master/src/Composer/Composer.php
|
|
* See https://github.com/composer/composer/blob/6587715d0f8cae0cd39073b3bc5f018d0e6b84fe/src/Composer/Compiler.php#L208
|
|
*/
|
|
final class VersionResolver
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
public const PACKAGE_VERSION = 'e3f20c1fb6665e7f0f6f84ced015f9eff86b6834';
|
|
/**
|
|
* @var string
|
|
*/
|
|
public const RELEASE_DATE = '2021-08-08 18:42:15';
|
|
public static function resolvePackageVersion() : string
|
|
{
|
|
$process = new \RectorPrefix20210808\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
|
if ($process->run() !== \RectorPrefix20210808\Symplify\PackageBuilder\Console\ShellCode::SUCCESS) {
|
|
throw new \Rector\Core\Exception\VersionException('You must ensure to run compile from composer git repository clone and that git binary is available.');
|
|
}
|
|
$version = \trim($process->getOutput());
|
|
return \trim($version, '"');
|
|
}
|
|
public static function resolverReleaseDateTime() : \DateTime
|
|
{
|
|
$process = new \RectorPrefix20210808\Symfony\Component\Process\Process(['git', 'log', '-n1', '--pretty=%ci', 'HEAD'], __DIR__);
|
|
if ($process->run() !== \RectorPrefix20210808\Symplify\PackageBuilder\Console\ShellCode::SUCCESS) {
|
|
throw new \Rector\Core\Exception\VersionException('You must ensure to run compile from composer git repository clone and that git binary is available.');
|
|
}
|
|
return new \DateTime(\trim($process->getOutput()));
|
|
}
|
|
}
|