-
-
Save mithereal/596a101e7b1bacf47d2a36af2a237e33 to your computer and use it in GitHub Desktop.
Current git version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class QuickGit { | |
private $version; | |
function __construct() { | |
if(function_exists('exec')) { | |
exec('git describe --always',$version_mini_hash,$error); | |
if($error == 0 ){ | |
exec('git rev-list HEAD | wc -l',$version_number); | |
exec('git log -1',$line); | |
exec('git rev-parse --abbrev-ref HEAD',$branch); | |
$this->version['branch'] = $branch[0]; | |
$this->version['short'] = $branch[0].".".trim($version_number[0]).".".$version_mini_hash[0]; | |
$this->version['full'] = $branch[0].".".trim($version_number[0]).".$version_mini_hash[0] (".str_replace('commit ','',$line[0]).")"; | |
}else{ | |
$this->version['error']="Ooops there was an Error: [ ". $error ." ]"; | |
} | |
}else{ | |
$this->version['error']="Error: [ exec not enabled ]"; | |
} | |
} | |
public function output() { | |
return $this->version; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment