Skip to content

Commit

Permalink
πŸ› make getVersion show the commit date, not checkout date
Browse files Browse the repository at this point in the history
Currently, getVersion() shows the date when the HEAD of the local git
repository was last changed, not the date of the current commit. This
commit fixes that behavior.
  • Loading branch information
micgro42 committed Jul 5, 2018
1 parent fdbbfed commit 6a381c5
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions inc/infoutils.php
Expand Up @@ -75,20 +75,8 @@ function getVersionData(){
$version['date'] = 'unknown';

$inventory = DOKU_INC.'.git/logs/HEAD';
if(is_file($inventory)){
$sz = filesize($inventory);
$seek = max(0,$sz-2000); // read from back of the file
$fh = fopen($inventory,'rb');
fseek($fh,$seek);
$chunk = fread($fh,2000);
fclose($fh);
$chunk = trim($chunk);
$chunk = @array_pop(explode("\n",$chunk)); //last log line
$chunk = @array_shift(explode("\t",$chunk)); //strip commit msg
$chunk = explode(" ",$chunk);
array_pop($chunk); //strip timezone
$date = date('Y-m-d',array_pop($chunk));
if($date) $version['date'] = $date;
if ($date = shell_exec("git log -1 --pretty=format:'%cd' --date=short")) {
$version['date'] = hsc($date);
}
}else{
global $updateVersion;
Expand Down

0 comments on commit 6a381c5

Please sign in to comment.