Last active
April 12, 2019 07:40
-
-
Save hongster/242e6202d206f1d65eb8 to your computer and use it in GitHub Desktop.
Generating build number from git branch name and commit count.
This file contains 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 | |
/** | |
* Generate a build number based on Git commit count and current branch. | |
* @return string Format: "{$branch}.{$commitCount}" | |
*/ | |
public function buildNumber() | |
{ | |
$branch = exec('git rev-parse --abbrev-ref HEAD'); | |
$commitCount = exec('git rev-list HEAD --count'); | |
return "{$branch}.{$commitCount}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment