| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- class git
- {
- public static function getCommitHash(){
- return substr(trim(exec('git log --pretty="%H" -n1 HEAD')), 0, 10);
- }
- public static function getCommitDate(){
- $commitDate = new \DateTime(trim(exec('git log -n1 --pretty=%ci HEAD')));
- $commitDate->setTimezone(new \DateTimeZone('Europe/Paris'));
- return $commitDate->format('d/m/Y à H:i:s');
- }
- public static function getCommitAuthor(){
- return exec('git log --pretty="%cn" -n1 HEAD');
- }
- public static function getCommitName(){
- return exec('git log --pretty="%s" -n1 HEAD');
- }
- public static function getBranchName(){
- return exec('git rev-parse --abbrev-ref HEAD');
- }
- public static function printVersion(){
- echo sprintf(
- '<h6>%s <span class="badge bg-info">%s</span> <span class="badge bg-success">%s</span></h6>
- <code>%s</code>
- <div class="media-body pb-3 mb-0 small lh-125">Le %s</div>',
- self::getCommitAuthor(),
- self::getBranchName(),
- self::getCommitHash(),
- self::getCommitName(),
- self::getCommitDate()
- );
- }
- }
|