Skip to content

Instantly share code, notes, and snippets.

@michielgerritsen
Last active April 11, 2017 14:23
Show Gist options
  • Save michielgerritsen/e715c1c0cface95f3ce0588c6a05031e to your computer and use it in GitHub Desktop.
Save michielgerritsen/e715c1c0cface95f3ce0588c6a05031e to your computer and use it in GitHub Desktop.
Retrieve the latest tag, based on the sorted version - https://packagist.org/packages/controlaltdelete/git-version
/**
* Retrieve the git version number so we can show it.
*/
$files = [];
$dir = dirname(dirname(dirname(__FILE__))) . '/.git/refs/tags';
if(file_exists($dir)) {
foreach (new DirectoryIterator($dir) as $file) {
if ($file->isDot()) {
continue;
}
$files[] = $file->getFilename();
}
natsort($files);
\View::share('gitTag', end($files));
} else {
\View::share('gitTag', 'v0.0.1');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment