Enhance [master] Show more git information (#2461)

make commit id clickable though to origin
display a status of the branch compared to remote
This commit is contained in:
Mafoo 2017-04-03 16:49:35 +01:00 committed by FusionPBX
parent dcfce8e443
commit 6ef6d24fac
2 changed files with 30 additions and 10 deletions

View File

@ -143,7 +143,7 @@ $text['label-switch']['uk'] = "перемикач";
$text['label-switch']['de-at'] = "Schalter";
$text['label-switch']['it-it'] = "Switch";
$text['label-git_branch']['en-us'] = "Branch:";
$text['label-git_branch']['en-us'] = "Branch";
$text['label-git_branch']['es-cl'] = "Rama";
$text['label-git_branch']['pt-pt'] = "Ramo";
$text['label-git_branch']['fr-fr'] = "Une succursale";
@ -152,9 +152,9 @@ $text['label-git_branch']['pl'] = "Gałąź";
$text['label-git_branch']['sv-se'] = "Gren";
$text['label-git_branch']['uk'] = "філія";
$text['label-git_branch']['de-at'] = "Ast";
$text['label-git_branch']['it-it'] = "Branch:";
$text['label-git_branch']['it-it'] = "Branch";
$text['label-git_commit']['en-us'] = "Commit:";
$text['label-git_commit']['en-us'] = "Commit";
$text['label-git_commit']['es-cl'] = "Cometer";
$text['label-git_commit']['pt-pt'] = "cometer";
$text['label-git_commit']['fr-fr'] = "Commettre";
@ -163,9 +163,9 @@ $text['label-git_commit']['pl'] = "Popełnić";
$text['label-git_commit']['sv-se'] = "Begå";
$text['label-git_commit']['uk'] = "здійснити";
$text['label-git_commit']['de-at'] = "Verpflichten";
$text['label-git_commit']['it-it'] = "Commit:";
$text['label-git_commit']['it-it'] = "Commit";
$text['label-git_origin']['en-us'] = "Origin:";
$text['label-git_origin']['en-us'] = "Origin";
$text['label-git_origin']['es-cl'] = "Origen";
$text['label-git_origin']['pt-pt'] = "Origem";
$text['label-git_origin']['fr-fr'] = "Origine";
@ -174,7 +174,18 @@ $text['label-git_origin']['pl'] = "Pochodzenie";
$text['label-git_origin']['sv-se'] = "Ursprung";
$text['label-git_origin']['uk'] = "походження";
$text['label-git_origin']['de-at'] = "Herkunft";
$text['label-git_origin']['it-it'] = "Origine:";
$text['label-git_origin']['it-it'] = "Origine";
$text['label-git_status']['en-us'] = "Status";
$text['label-git_status']['es-cl'] = "Estado de";
$text['label-git_status']['pt-pt'] = "Status do";
$text['label-git_status']['fr-fr'] = "Statut";
$text['label-git_status']['pt-br'] = "Status do";
$text['label-git_status']['pl'] = "Status";
$text['label-git_status']['sv-se'] = "Status";
$text['label-git_status']['uk'] = "Статус";
$text['label-git_status']['de-at'] = "Status";
$text['label-git_status']['it-it'] = "Stato";
$text['label-memcache_status']['en-us'] = "Memcache Status";
$text['label-memcache_status']['es-cl'] = "Estado de Memcache";

View File

@ -89,20 +89,29 @@ $document['title'] = $text['title-sys-status'];
if(file_exists($git_path)){
$git_exe = 'git';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'SUN') { $git_exe = shell_exec('which git'); }
shell_exec($git_exe.' --git-dir='.$git_path.' fetch');
$git_branch = shell_exec($git_exe.' --git-dir='.$git_path.' name-rev --name-only HEAD');
rtrim($git_branch);
$git_commit = shell_exec($git_exe.' --git-dir='.$git_path.' rev-parse HEAD');
rtrim($git_commit);
$git_origin = shell_exec($git_exe.' --git-dir='.$git_path.' config --get remote.origin.url');
rtrim($git_commit);
rtrim($git_origin);
$git_origin = preg_replace('/\.git$/','',$git_origin);
$git_status = shell_exec($git_exe.' --git-dir='.$git_path.' status | grep "Your branch"');
rtrim($git_status);
$git_age = shell_exec($git_exe.' --git-dir='.$git_path.' log --pretty=format:%at HEAD^!');
rtrim($git_age);
$git_date = DateTime::createFromFormat('U', $git_age);
$git_age = $git_date->diff(new DateTime('now'));
echo "<tr>\n";
echo " <td width='20%' class=\"vncell\" style='text-align: left;'>\n";
echo " ".$text['label-git_info']."\n";
echo " </td>\n";
echo " <td class=\"row_style1\">\n";
echo " ".$text['label-git_branch']." ".$git_branch."<br>\n";
echo " ".$text['label-git_commit']." ".$git_commit."<br>\n";
echo " ".$text['label-git_origin']." ".$git_origin."<br>\n";
echo " ".$text['label-git_branch'].": ".$git_branch."<br>\n";
echo " ".$text['label-git_commit'].": <a href='$git_origin/commit/$git_commit'>".$git_commit."</a><br>\n";
echo " ".$text['label-git_origin'].": ".$git_origin."<br>\n";
echo " ".$text['label-git_status'].": ".$git_status.$git_age->format(' %R%a days ago')."<br>\n";
echo " </td>\n";
echo "</tr>\n";
}