Skip to content

Instantly share code, notes, and snippets.

@dmdeller
Created March 11, 2010 16:52
Show Gist options
  • Save dmdeller/329337 to your computer and use it in GitHub Desktop.
Save dmdeller/329337 to your computer and use it in GitHub Desktop.
<?php
/**
* get current git revision
*/
if (sfConfig::get('sf_environment') != 'prod' && file_exists(sfConfig::get('sf_root_dir').'/../.git/logs/HEAD'))
{
$fp = fopen(sfConfig::get('sf_root_dir').'/../.git/logs/HEAD', 'r');
$pos = -2; $line = ''; $c = '';
do {
$line = $c . $line;
fseek($fp, $pos--, SEEK_END);
$c = fgetc($fp);
} while ($c != "\n" && $c !== false);
list(, $rev) = explode(' ', $line);
$rev = substr($rev, 0, 10);
sfConfig::set('app_git_revision', $rev);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment