DGI fixes
This commit is contained in:
@@ -8,14 +8,17 @@ require_once (__DIR__ . '/../internals/website.php');
|
||||
|
||||
if (!isset($API_OPTIONS['field'])) { $FRAME_OPTIONS->forceResult(400, "Wrong parameters."); return; }
|
||||
|
||||
$info = $SITE->gitStatus();
|
||||
|
||||
function printInfo($v) { if ($v === false) throw new Exception('Failed to query field'); else echo $v; }
|
||||
|
||||
$field = strtolower($API_OPTIONS['field']);
|
||||
|
||||
if ($field === 'branch') { echo exec('git rev-parse --abbrev-ref HEAD'); return; }
|
||||
if ($field === 'head') { echo exec('git rev-parse HEAD'); return; }
|
||||
if ($field === 'timestamp') { echo (new DateTime(exec('git log -1 --format=%cd --date=iso')))->format('Y-m-d H:i:s'); return; }
|
||||
if ($field === 'origin') { echo exec('git config --get remote.origin.url'); return; }
|
||||
if ($field === 'message') { echo trim(shell_exec('git log -1 --format=%B')); return; }
|
||||
|
||||
if ($field === 'branch') { printInfo($info[0]); return; }
|
||||
if ($field === 'head') { printInfo($info[1]); return; }
|
||||
if ($field === 'timestamp') { printInfo($info[3]); return; }
|
||||
if ($field === 'origin') { printInfo(str_replace(';', "\n", $info[4])); return; }
|
||||
if ($field === 'message') { printInfo($info[5]); return; }
|
||||
|
||||
$FRAME_OPTIONS->statuscode = 400;
|
||||
echo 'Unknown field';
|
||||
|
||||
Reference in New Issue
Block a user