| 1234567891011121314151617181920212223242526272829303132 |
- <?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('UTC'));
- 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 printVersion(){
- echo sprintf(
- '<h6>%s <span class="badge bg-success">%s</h6></div><div>%s (%s)</div>',
- self::getCommitAuthor(),
- self::getCommitHash(),
- self::getCommitName(),
- self::getCommitDate()
- );
- }
- }
|