Last active
December 11, 2018 08:06
-
-
Save lukeocodes/5501074 to your computer and use it in GitHub Desktop.
Revisions
-
lukeocodes revised this gist
Feb 27, 2017 . 1 changed file with 65 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,69 @@ <?php class QuickGit { /** @var int */ private $major = 1; /** @var int */ private $minor = 0; /** @var string */ private $patch = ''; /** @var int */ private $commits = 0; /** @var string */ private $commit = ''; /** * @method __construct */ public function __construct() { // Collect git data. exec('git describe --always', $gitHashShort); $this->patch = $gitHashShort; exec('git rev-list HEAD | wc -l', $gitCommits); $this->commits = $gitCommits; exec('git log -1', $gitHashLong); $this->commit = $gitHashLong; } /** * @return string */ public function toString($format = 'short') { switch ($format) { case 'long': return sprintf( '%d.%d.%s (#%d, %s)', $this->major, $this->minor, $this->patch, $this->commits, $this->commit ); default: return sprintf( '%d.%d.%s', $this->major, $this->minor, $this->patch ); } } /** * @method __toString */ public function __toString() { return $this->toString(); } } -
lukeocodes revised this gist
Jun 10, 2013 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,22 @@ <?php class QuickGit { private $version; function __construct() { exec('git describe --always',$version_mini_hash); exec('git rev-list HEAD | wc -l',$version_number); exec('git log -1',$line); $this->version['short'] = "v1.".trim($version_number[0]).".".$version_mini_hash[0]; $this->version['full'] = "v1.".trim($version_number[0]).".$version_mini_hash[0] (".str_replace('commit ','',$line[0]).")"; } public function output() { return $this->version; } public function show() { echo $this->version; } } -
lukeocodes revised this gist
May 2, 2013 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,16 @@ <?php class QuickGit { public function __construct() { exec('git describe --always',$version_mini_hash); exec('git rev-list HEAD | wc -l',$version_number); exec('git log -1',$line); $version['short'] = "v1.".trim($version_number[0]).".".$version_mini_hash[0]; $version['full'] = "v1.".trim($version_number[0]).".$version_mini_hash[0] (".str_replace('commit ','',$line[0]).")"; return $version; } } -
lukeocodes created this gist
May 2, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ <?php class QuickGit { public static function version() { exec('git describe --always',$version_mini_hash); exec('git rev-list HEAD | wc -l',$version_number); exec('git log -1',$line); $version['short'] = "v1.".trim($version_number[0]).".".$version_mini_hash[0]; $version['full'] = "v1.".trim($version_number[0]).".$version_mini_hash[0] (".str_replace('commit ','',$line[0]).")"; return $version; } }