2021-05-14 21:57:41 +00:00
< ? php
2021-05-19 00:22:02 +00:00
declare ( strict_types = 1 );
2021-05-14 21:57:41 +00:00
namespace Rector\Core\Application ;
2021-05-19 00:12:47 +00:00
use DateTimeInterface ;
use Rector\Core\Exception\VersionException ;
2021-05-19 00:22:02 +00:00
use RectorPrefix20210519\Symfony\Component\Process\Process ;
use RectorPrefix20210519\Symplify\PackageBuilder\Console\ShellCode ;
2021-05-14 21:57:41 +00:00
/**
2021-05-19 00:12:47 +00:00
* Inspired by https :// github . com / composer / composer / blob / master / src / Composer / Composer . php
* See https :// github . com / composer / composer / blob / 6587715 d0f8cae0cd39073b3bc5f018d0e6b84fe / src / Composer / Compiler . php #L208
2021-05-14 21:57:41 +00:00
*/
final class VersionResolver
{
2021-05-19 00:12:47 +00:00
/**
* @ var string
*/
2021-05-19 08:12:18 +00:00
public const PACKAGE_VERSION = '"16b51b8226b05e04be7e463d098072b02835fbbf"' ;
2021-05-19 00:12:47 +00:00
/**
* @ var string
*/
2021-05-19 08:12:18 +00:00
public const RELEASE_DATE = '2021-05-19 08:04:18' ;
2021-05-19 00:22:02 +00:00
public static function resolvePackageVersion () : string
2021-05-14 21:57:41 +00:00
{
2021-05-19 00:22:02 +00:00
$process = new \RectorPrefix20210519\Symfony\Component\Process\Process ([ 'git' , 'log' , '--pretty="%H"' , '-n1' , 'HEAD' ], __DIR__ );
if ( $process -> run () !== \RectorPrefix20210519\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.' );
2021-05-14 21:57:41 +00:00
}
2021-05-19 00:22:02 +00:00
return \trim ( $process -> getOutput ());
2021-05-14 21:57:41 +00:00
}
2021-05-19 00:22:02 +00:00
public static function resolverReleaseDateTime () : \DateTimeInterface
2021-05-14 21:57:41 +00:00
{
2021-05-19 00:22:02 +00:00
$process = new \RectorPrefix20210519\Symfony\Component\Process\Process ([ 'git' , 'log' , '-n1' , '--pretty=%ci' , 'HEAD' ], __DIR__ );
if ( $process -> run () !== \RectorPrefix20210519\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.' );
2021-05-19 00:12:47 +00:00
}
2021-05-19 00:22:02 +00:00
return new \DateTime ( \trim ( $process -> getOutput ()));
2021-05-14 21:57:41 +00:00
}
}