From 27ffe2c52420eb8fe47746cd8f74f7110cbb02ed Mon Sep 17 00:00:00 2001 From: Dario Mratovich Date: Wed, 12 Oct 2022 16:42:22 +0800 Subject: [PATCH 1/2] Ensure updatenotification module isn't shown when local is *ahead* of remote Update Regex to match status info. Only notify when repo's commits are 'behind'. Use Regex capturing groups to extract git info. --- CHANGELOG.md | 1 + .../default/updatenotification/git_helper.js | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9361b2da1a..e8293eb426 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Special thanks to: @rejas, @sdetweil ### Fixed - Correctly show apparent temperature in SMHI weather provider +- Ensure updatenotification module isn't shown when local is *ahead* of remote ## [2.21.0] - 2022-10-01 diff --git a/modules/default/updatenotification/git_helper.js b/modules/default/updatenotification/git_helper.js index b42b7d5cc1..80cb75320a 100644 --- a/modules/default/updatenotification/git_helper.js +++ b/modules/default/updatenotification/git_helper.js @@ -92,20 +92,18 @@ class GitHelper { // examples for status: // ## develop...origin/develop // ## master...origin/master [behind 8] - status = status.match(/(?![.#])([^.]*)/g); + // ## master...origin/master [ahead 8, behind 1] + status = status.match(/## (.*)\.\.\.([^ ]*)(?: .*behind (\d+))?/); // examples for status: - // [ ' develop', 'origin/develop', '' ] - // [ ' master', 'origin/master [behind 8]', '' ] - gitInfo.current = status[0].trim(); - status = status[1].split(" "); - // examples for status: - // [ 'origin/develop' ] - // [ 'origin/master', '[behind', '8]' ] - gitInfo.tracking = status[0].trim(); + // [ '## develop...origin/develop', 'develop', 'origin/develop' ] + // [ '## master...origin/master [behind 8]', 'master', 'origin/master', '8' ] + // [ '## master...origin/master [ahead 8, behind 1]', 'master', 'origin/master', '1' ] + gitInfo.current = status[1]; + gitInfo.tracking = status[2]; - if (status[2]) { + if (status[3]) { // git fetch was already called before so `git status -sb` delivers already the behind number - gitInfo.behind = parseInt(status[2].substring(0, status[2].length - 1)); + gitInfo.behind = parseInt(status[3]); gitInfo.isBehindInStatus = true; } From 493d7462d3f89566f217a3d5f097b2149e64b9af Mon Sep 17 00:00:00 2001 From: Dario Mratovich Date: Wed, 12 Oct 2022 17:03:37 +0800 Subject: [PATCH 2/2] Fix code style issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forgot to run prettier after updating CHANGELOG 🤦🏼 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8293eb426..53adcc6983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ Special thanks to: @rejas, @sdetweil ### Fixed - Correctly show apparent temperature in SMHI weather provider -- Ensure updatenotification module isn't shown when local is *ahead* of remote +- Ensure updatenotification module isn't shown when local is _ahead_ of remote ## [2.21.0] - 2022-10-01