diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3a1c4a..e15b060c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ _This release is scheduled to be released on 2023-04-01._ - Added increments for hourly forecasts in weather module (#2996) - Added tests for hourly weather forecast +- Added possibility to ignore MagicMirror repo in updatenotification module ### Removed diff --git a/modules/default/updatenotification/git_helper.js b/modules/default/updatenotification/git_helper.js index 80cb7532..e793ebc9 100644 --- a/modules/default/updatenotification/git_helper.js +++ b/modules/default/updatenotification/git_helper.js @@ -36,7 +36,7 @@ class GitHelper { async add(moduleName) { let moduleFolder = BASE_DIR; - if (moduleName !== "default") { + if (moduleName !== "MagicMirror") { moduleFolder = `${moduleFolder}modules/${moduleName}`; } @@ -68,7 +68,7 @@ class GitHelper { isBehindInStatus: false }; - if (repo.module === "default") { + if (repo.module === "MagicMirror") { // the hash is only needed for the mm repo const { stderr, stdout } = await this.execShell(`cd ${repo.folder} && git rev-parse HEAD`); @@ -121,7 +121,7 @@ class GitHelper { return gitInfo; } - const { stderr } = await this.execShell(`cd ${repo.folder} && git fetch --dry-run`); + const { stderr } = await this.execShell(`cd ${repo.folder} && git fetch -n --dry-run`); // example output: // From https://github.com/MichMich/MagicMirror @@ -129,14 +129,16 @@ class GitHelper { // here the result is in stderr (this is a git default, don't ask why ...) const matches = stderr.match(this.getRefRegex(gitInfo.current)); - if (!matches || !matches[0]) { - // no refs found, nothing to do - return; + // this is the default if there was no match from "git fetch -n --dry-run". + // Its a fallback because if there was a real "git fetch", the above "git fetch -n --dry-run" would deliver nothing. + let refDiff = gitInfo.current + "..origin/" + gitInfo.current; + if (matches && matches[0]) { + refDiff = matches[0]; } // get behind with refs try { - const { stdout } = await this.execShell(`cd ${repo.folder} && git rev-list --ancestry-path --count ${matches[0]}`); + const { stdout } = await this.execShell(`cd ${repo.folder} && git rev-list --ancestry-path --count ${refDiff}`); gitInfo.behind = parseInt(stdout); return gitInfo; diff --git a/modules/default/updatenotification/node_helper.js b/modules/default/updatenotification/node_helper.js index a0e68305..9db4354f 100644 --- a/modules/default/updatenotification/node_helper.js +++ b/modules/default/updatenotification/node_helper.js @@ -19,7 +19,9 @@ module.exports = NodeHelper.create({ } } - await this.gitHelper.add("default"); + if (!this.ignoreUpdateChecking("MagicMirror")) { + await this.gitHelper.add("MagicMirror"); + } }, async socketNotificationReceived(notification, payload) { diff --git a/modules/default/updatenotification/updatenotification.js b/modules/default/updatenotification/updatenotification.js index 7b4945c9..602e76f4 100644 --- a/modules/default/updatenotification/updatenotification.js +++ b/modules/default/updatenotification/updatenotification.js @@ -77,7 +77,7 @@ Module.register("updatenotification", { addFilters() { this.nunjucksEnvironment().addFilter("diffLink", (text, status) => { - if (status.module !== "default") { + if (status.module !== "MagicMirror") { return text; } diff --git a/modules/default/updatenotification/updatenotification.njk b/modules/default/updatenotification/updatenotification.njk index 3149816f..77d79754 100644 --- a/modules/default/updatenotification/updatenotification.njk +++ b/modules/default/updatenotification/updatenotification.njk @@ -3,7 +3,7 @@