Skip to content
Permalink
Browse files

πŸ‘Œ Add fallback if we cannot use git on the shell

Under some circumstances, there may be no git or no shell access available. This gets the commit
date manually.
  • Loading branch information...
micgro42 committed Jul 5, 2018
1 parent 067b4fb commit f519f9dbd38c1c52b28244ed9adfab8b6ff9561b
Showing with 19 additions and 0 deletions.
  1. +19 βˆ’0 inc/infoutils.php
@@ -76,6 +76,25 @@ function getVersionData(){
if ($date = shell_exec("git log -1 --pretty=format:'%cd' --date=short")) {
$version['date'] = hsc($date);
} else if (file_exists(DOKU_INC . '.git/HEAD')) {
// we cannot use git on the shell -- let's do it manually!
$headCommit = trim(file_get_contents(DOKU_INC . '.git/HEAD'));
if (strpos($headCommit, 'ref: ') === 0) {
// it is something like `ref: refs/heads/master`
$pathToHead = substr($headCommit, 5);
$headCommit = trim(file_get_contents(DOKU_INC . '.git/' . $pathToHead));
}
$subDir = substr($headCommit, 0, 2);
$fileName = substr($headCommit, 2);
$getCommitObject = DOKU_INC . ".git/objects/$subDir/$fileName";
$commit = zlib_decode(file_get_contents($getCommitObject));
$committerLine = explode("\n", $commit)[3];
$committerData = explode(' ', $committerLine);
end($committerData);
$ts = prev($committerData);
if ($ts && $date = date('Y-m-d', $ts)) {
$version['date'] = $date;
}
}
}else{
global $updateVersion;

0 comments on commit f519f9d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.