Skip to content

Instantly share code, notes, and snippets.

@jairoFernandez
Created July 12, 2017 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jairoFernandez/f20075080c388683094193f8fe9d8bf6 to your computer and use it in GitHub Desktop.
Save jairoFernandez/f20075080c388683094193f8fe9d8bf6 to your computer and use it in GitHub Desktop.
Obtain_last_version_git_PHP
public function ObtainLastVersionCode($directoryCode)
{
try{
$dir = $directoryCode;
chdir($dir);
$version = 'git rev-parse --verify HEAD';
$comment = 'git log -1 --pretty=%B';
$date = 'git log -1 --format=%cd --date=local';
$outputVersion = shell_exec($version);
$outputComment = shell_exec($comment);
$outputDate = shell_exec($date);
return ['Version'=>$outputVersion, 'Comment'=>$outputComment, 'Date'=>$outputDate];
}catch (Exception $e){
return $e;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment