From 292e63c76cb736f3e8ea6473363671e06df40e43 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:54:03 -0500 Subject: [PATCH] better update count --- homepage/views.php | 6 +++++- scripts/system_controls.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/homepage/views.php b/homepage/views.php index 85f3d84..0544c88 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -6,7 +6,11 @@ $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = trim($home); if(!isset($_SESSION['behind'])) { $fetch = shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch 2>&1"); - $_SESSION['behind'] = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7")); + $str = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status")); + if (preg_match("/behind '.*?' by (\d+) commit(s?)\b/", $str, $matches)) { + $num_commits_behind = $matches[1]; + $_SESSION['behind'] = $num_commits_behind; + } if(isset($_SESSION['behind'])&&intval($_SESSION['behind']) >= 99) {?>