Created
March 2, 2014 19:59
-
-
Save mikkohei13/9312874 to your computer and use it in GitHub Desktop.
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
/** | |
* Gets the last commit date from .git repository | |
* @param string $gitLocation location of .git/logs/HEAD | |
* @return string date of last commit YYYY-mm-dd | |
*/ | |
function gitLastCommitInfo($gitLocation) | |
{ | |
$commitArray = file($gitLocation); // All commits from file | |
$lastCommit = array_pop($commitArray); // Latest commit | |
$lastCommitArray = explode("\t", $lastCommit); | |
$lastCommitArray2 = explode(" ", $lastCommitArray[0]); | |
$pop = array_pop($lastCommitArray2); // Remove last array item | |
return date("Y-m-d", array_pop($lastCommitArray2)); // Format date from second-to-last array item | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment