Skip to content
Snippets Groups Projects
Commit 40a0d685 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

better getVersion when working on a darcs tree

getVersion tries to find the date of the latest applied patch from
_darcs/inventory - this patch makes it only read the last 2000 byte
of the file instead of loading the whole file.

darcs-hash:20060916182955-7ad00-5a38de1ae4f1a206a8f62cc88551d4f0bc35340e.gz
parent 7bff22c0
No related branches found
Tags develsnap_2006-09-13
No related merge requests found
......@@ -979,9 +979,14 @@ function getVersion(){
//official release
return 'Release '.trim(io_readfile(DOKU_INC.'/VERSION'));
}elseif(is_dir('_darcs')){
//darcs checkout
$inv = file('_darcs/inventory');
$inv = preg_grep('#\*\*\d{14}[\]$]#',$inv);
//darcs checkout - read last 2000 bytes of inventory
$sz = filesize('_darcs/inventory');
$seek = max(0,$sz-2000);
$fh = fopen('_darcs/inventory','rb');
fseek($fh,$seek);
$chunk = fread($fh,2000);
fclose($fh);
$inv = preg_grep('#\*\*\d{14}[\]$]#',explode("\n",$chunk));
$cur = array_pop($inv);
preg_match('#\*\*(\d{4})(\d{2})(\d{2})#',$cur,$matches);
return 'Darcs '.$matches[1].'-'.$matches[2].'-'.$matches[3];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment