From 047ecaffd23423a85c85973ca8bc5964cb8f5bee Mon Sep 17 00:00:00 2001 From: Mafoo Date: Thu, 13 Apr 2017 17:07:21 +0100 Subject: [PATCH] BugFix [master] system information git (#2499) fix for if the .git folder is present but corrupt --- app/system/app_languages.php | 11 +++++++ app/system/system.php | 61 +++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/app/system/app_languages.php b/app/system/app_languages.php index d91c386113..58332d9567 100644 --- a/app/system/app_languages.php +++ b/app/system/app_languages.php @@ -132,6 +132,17 @@ $text['label-git_info']['uk'] = "Гіт інформація"; $text['label-git_info']['de-at'] = "Git Informationen"; $text['label-git_info']['it-it'] = "Informazioni Git"; +$text['label-git_corrupted']['en-us'] = "Git data is corrupt"; +$text['label-git_corrupted']['es-cl'] = "Git datos es corrupto"; +$text['label-git_corrupted']['pt-pt'] = "Dados Git é corrupto"; +$text['label-git_corrupted']['fr-fr'] = "Données Git est corrompu"; +$text['label-git_corrupted']['pt-br'] = "Dados Git é corrupto"; +$text['label-git_corrupted']['pl'] = "Git danych jest uszkodzony"; +$text['label-git_corrupted']['sv-se'] = "Git uppgifter är korrupt"; +$text['label-git_corrupted']['uk'] = "Гіт дані пошкоджені"; +$text['label-git_corrupted']['de-at'] = "Git Daten ist beschädigt" ; +$text['label-git_corrupted']['it-it'] = "Dati Git è corrotto"; + $text['label-switch']['en-us'] = "Switch"; $text['label-switch']['es-cl'] = "Cambiar"; $text['label-switch']['pt-pt'] = "Interruptor"; diff --git a/app/system/system.php b/app/system/system.php index 96738976a8..98611f6cb6 100644 --- a/app/system/system.php +++ b/app/system/system.php @@ -89,31 +89,42 @@ $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_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 "\n"; - echo " \n"; - echo " ".$text['label-git_info']."\n"; - echo " \n"; - echo " \n"; - echo " ".$text['label-git_branch'].": ".$git_branch."
\n"; - echo " ".$text['label-git_commit'].": ".$git_commit."
\n"; - echo " ".$text['label-git_origin'].": ".$git_origin."
\n"; - echo " ".$text['label-git_status'].": ".$git_status.$git_age->format(' %R%a days ago')."
\n"; - echo " \n"; - echo "\n"; + exec($git_exe.' --git-dir='.$git_path.' fetch', $dummy, $returnCode); + if($returnCode){ + echo "\n"; + echo " \n"; + echo " ".$text['label-git_info']."\n"; + echo " \n"; + echo " \n"; + echo " ".$text['label-git_corrupted']."\n"; + echo " \n"; + echo "\n"; + }else{ + $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_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 "\n"; + echo " \n"; + echo " ".$text['label-git_info']."\n"; + echo " \n"; + echo " \n"; + echo " ".$text['label-git_branch'].": ".$git_branch."
\n"; + echo " ".$text['label-git_commit'].": ".$git_commit."
\n"; + echo " ".$text['label-git_origin'].": ".$git_origin."
\n"; + echo " ".$text['label-git_status'].": ".$git_status.$git_age->format(' %R%a days ago')."
\n"; + echo " \n"; + echo "\n"; + } } echo "\n";