From b3228b808c009d9124fd4ac813592944bc0d42ef Mon Sep 17 00:00:00 2001 From: "tobias.wolf" Date: Thu, 26 Apr 2018 11:26:42 +0200 Subject: [PATCH 1/2] Show git status in Widget e.g. "Your branch is ahead of 'origin/master' by 2 commits." --- lib/autogit.php | 5 +++++ widgets/autogit/template.php | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) mode change 100755 => 100644 lib/autogit.php diff --git a/lib/autogit.php b/lib/autogit.php old mode 100755 new mode 100644 index 4a4df12..853bc8c --- a/lib/autogit.php +++ b/lib/autogit.php @@ -62,6 +62,11 @@ public function push() $this->execute("push {$this->remoteName} {$this->remoteBranch} 2>&1"); } + public function getStatus() + { + return $this->execute("status 2>&1")[1]; + } + public function hasRemote($remoteName = null) { $remoteName = $remoteName ? $remoteName : $this->remoteName; diff --git a/widgets/autogit/template.php b/widgets/autogit/template.php index a6e0624..fed9d60 100644 --- a/widgets/autogit/template.php +++ b/widgets/autogit/template.php @@ -22,9 +22,6 @@ margin-top: .5em; text-align: center; } -.autogit-status { - display: none; } - .autogit-warning { color: #b3000a; } @@ -57,7 +54,7 @@ Get latest changes -
+
getStatus() ?>
Could not detect remote repository . @@ -87,22 +84,22 @@ $.post(panelURL + '/autogit/' + $button.data('action')) .done(function (res) { $button.find('.icon').replaceWith($successIcon) - $status.text(res.message).show(600) + $status.text(res.message).show(0) }) .fail(function (res) { $button.find('.icon').replaceWith($errorIcon) $button.removeClass('btn-positive').addClass('btn-negative') - $status.text(res.responseJSON.message).show(600) + $status.text(res.responseJSON.message).show(0) }) .always(function () { setTimeout(function () { $button.find('.icon').replaceWith($defaultIcon) $button.removeClass('btn-negative').addClass('btn-positive') $otherButton.prop('disabled', false) - $status.hide(600, function () { + $status.hide(0, function () { $(this).text('') }) - }, 6000) + }, 10000) }) }) From ed98b1f188b5f9bacd3a737a3295081489585abc Mon Sep 17 00:00:00 2001 From: "tobias.wolf" Date: Wed, 2 May 2018 13:51:12 +0200 Subject: [PATCH 2/2] Clear Cache after Pull --- lib/autogit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/autogit.php b/lib/autogit.php index 853bc8c..f3252f1 100644 --- a/lib/autogit.php +++ b/lib/autogit.php @@ -55,6 +55,7 @@ public function commit($message) public function pull() { $this->execute("pull {$this->remoteName} {$this->remoteBranch} 2>&1"); + kirby()->cache()->flush(); } public function push()