mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
fix update notification, remove simple-git
This commit is contained in:
parent
860840c367
commit
22384342db
@ -30,6 +30,7 @@ _This release is scheduled to be released on 2021-10-01._
|
|||||||
- Fix undefined error with ignoreToday option in weather module (#2620).
|
- Fix undefined error with ignoreToday option in weather module (#2620).
|
||||||
- Fix time zone correction in calendar module when the date hour is equal to the time zone correction value (#2632).
|
- Fix time zone correction in calendar module when the date hour is equal to the time zone correction value (#2632).
|
||||||
- Fix black cursor on startup when using electron.
|
- Fix black cursor on startup when using electron.
|
||||||
|
- Fix update notification not working for own repository (#2644).
|
||||||
|
|
||||||
## [2.16.0] - 2021-07-01
|
## [2.16.0] - 2021-07-01
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const { exec } = require("child_process");
|
const util = require("util");
|
||||||
|
const exec = util.promisify(require("child_process").exec);
|
||||||
const gitRepos = [];
|
const gitRepos = [];
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
@ -55,20 +56,26 @@ module.exports = NodeHelper.create({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
isGitRepo: function (moduleFolder) {
|
execShell: async function (command) {
|
||||||
exec("cd " + moduleFolder + " && git remote -v", (err, stdout, stderr) => {
|
let res = { stdout: "", stderr: "" };
|
||||||
if (err) {
|
const { stdout, stderr } = await exec(command);
|
||||||
Log.error("Failed to fetch git data for " + moduleFolder + ": " + err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
res.stdout = stdout;
|
||||||
|
res.stderr = stderr;
|
||||||
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isGitRepo: async function (moduleFolder) {
|
||||||
|
let res = await this.execShell("cd " + moduleFolder + " && git remote -v");
|
||||||
|
if (res.stderr) {
|
||||||
|
Log.error("Failed to fetch git data for " + moduleFolder + ": " + res.stderr);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
performFetch: function () {
|
getRepoInfo: async function (repo) {
|
||||||
for (let repo of gitRepos) {
|
|
||||||
let gitInfo = {
|
let gitInfo = {
|
||||||
module: repo.module,
|
module: repo.module,
|
||||||
// commits behind:
|
// commits behind:
|
||||||
@ -80,64 +87,49 @@ module.exports = NodeHelper.create({
|
|||||||
// remote branch:
|
// remote branch:
|
||||||
tracking: ""
|
tracking: ""
|
||||||
};
|
};
|
||||||
exec("cd " + repo.folder + " && git rev-parse HEAD", (err, stdout, stderr) => {
|
let res = await this.execShell("cd " + repo.folder + " && git rev-parse HEAD");
|
||||||
if (err) {
|
if (res.stderr) {
|
||||||
Log.error("Failed to get current commit hash for " + repo.module + ": " + err + " " + stderr);
|
Log.error("Failed to get current commit hash for " + repo.module + ": " + res.stderr);
|
||||||
} else {
|
}
|
||||||
// console.log(stdout);
|
gitInfo.hash = res.stdout;
|
||||||
gitInfo.hash = stdout;
|
res = await this.execShell("cd " + repo.folder + " && git status -sb");
|
||||||
// console.log("hash: " + gitInfo.hash);
|
if (res.stderr) {
|
||||||
exec("cd " + repo.folder + " && git status -sb", (err, stdout, stderr) => {
|
Log.error("Failed to get git status for " + repo.module + ": " + res.stderr);
|
||||||
if (err) {
|
// exit without git status info
|
||||||
Log.error("Failed to get git status for " + repo.module + ": " + err + " " + stderr);
|
return;
|
||||||
} else {
|
}
|
||||||
let status = stdout.split("\n")[0];
|
// get branch and remote
|
||||||
// console.log(repo.module);
|
let status = res.stdout.split("\n")[0];
|
||||||
status = status.match(/(?![.#])([^.]*)/g);
|
status = status.match(/(?![.#])([^.]*)/g);
|
||||||
gitInfo.current = status[0].trim();
|
gitInfo.current = status[0].trim();
|
||||||
// console.log("current: " + gitInfo.current);
|
|
||||||
status = status[1].split(" ");
|
status = status[1].split(" ");
|
||||||
gitInfo.tracking = status[0].trim();
|
gitInfo.tracking = status[0].trim();
|
||||||
// console.log("tracking: " + gitInfo.tracking);
|
|
||||||
if (status[2]) {
|
if (status[2]) {
|
||||||
|
// 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[2].substring(0, status[2].length - 1));
|
||||||
// console.log("behind: " + gitInfo.behind);
|
return gitInfo;
|
||||||
this.sendSocketNotification("STATUS", gitInfo);
|
}
|
||||||
} else {
|
res = await this.execShell("cd " + repo.folder + " && git fetch --dry-run");
|
||||||
exec("cd " + repo.folder + " && git fetch --dry-run", (err, stdout, stderr) => {
|
// here the result is in stderr
|
||||||
if (err) {
|
if (res.stderr === "") return;
|
||||||
Log.error("Failed to fetch git data for " + repo.module + ": " + err);
|
// set default > 0
|
||||||
} else {
|
|
||||||
// console.log(repo.module);
|
|
||||||
// console.dir(stderr);
|
|
||||||
if (stderr !== "") {
|
|
||||||
// get behind
|
|
||||||
gitInfo.behind = 1;
|
gitInfo.behind = 1;
|
||||||
let refs = stderr.split('\n')[1].match(/s*([a-z,0-9]+[\.]+[a-z,0-9]+)s*/g)[0];
|
let refs = res.stderr.match(/s*([a-z,0-9]+[.][.][a-z,0-9]+)s*/g)[0];
|
||||||
// console.dir(refs);
|
|
||||||
if (refs === "") {
|
if (refs === "") {
|
||||||
|
return gitInfo;
|
||||||
|
}
|
||||||
|
res = await this.execShell("cd " + repo.folder + " && git rev-list --ancestry-path --count " + refs);
|
||||||
|
gitInfo.behind = parseInt(res.stdout);
|
||||||
|
return gitInfo;
|
||||||
|
},
|
||||||
|
|
||||||
|
performFetch: async function () {
|
||||||
|
for (let repo of gitRepos) {
|
||||||
|
const gitInfo = await this.getRepoInfo(repo);
|
||||||
|
if (gitInfo) {
|
||||||
this.sendSocketNotification("STATUS", gitInfo);
|
this.sendSocketNotification("STATUS", gitInfo);
|
||||||
} else {
|
|
||||||
exec("cd " + repo.folder + " && git rev-list --ancestry-path --count " + refs, (err, stdout, stderr) => {
|
|
||||||
gitInfo.behind = parseInt(stdout);
|
|
||||||
// console.log("behind: " + gitInfo.behind);
|
|
||||||
this.sendSocketNotification("STATUS", gitInfo);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// let gitInfo = await this.getGitData(repo);
|
|
||||||
// if (gitInfo) {
|
|
||||||
// console.dir(gitInfo);
|
|
||||||
// this.sendSocketNotification("STATUS", gitInfo);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
this.scheduleNextFetch(this.config.updateInterval);
|
this.scheduleNextFetch(this.config.updateInterval);
|
||||||
},
|
},
|
||||||
@ -169,9 +161,3 @@ module.exports = NodeHelper.create({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// [03.09.2021 23:02.36.382] [LOG] hash: e19a42879896d2d8e2406fcb3fd4fdcf15d2ed6b
|
|
||||||
// [03.09.2021 23:02.36.382] [LOG] trackingorigin/master
|
|
||||||
// [03.09.2021 23:02.36.714] [LOG] hash: e40ddd4b69424349768b7e451d9c4f52ac4efe45
|
|
||||||
// [03.09.2021 23:02.36.714] [LOG] trackingorigin/develop
|
|
||||||
|
21
package-lock.json
generated
21
package-lock.json
generated
@ -23,7 +23,6 @@
|
|||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"node-ical": "^0.13.0",
|
"node-ical": "^0.13.0",
|
||||||
"simple-git": "^2.45.0",
|
|
||||||
"socket.io": "^4.1.3"
|
"socket.io": "^4.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -8707,16 +8706,6 @@
|
|||||||
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==",
|
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/simple-git": {
|
|
||||||
"version": "2.45.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.45.0.tgz",
|
|
||||||
"integrity": "sha512-wu/Ujs9IXn0HuyYm4HyRvne+EKsjJSWKEMkB3wQa3gNHSMHt7y3oeNX9zRQ3UBPk7bRRMLLHAdIZCZfHT9ehPg==",
|
|
||||||
"dependencies": {
|
|
||||||
"@kwsites/file-exists": "^1.1.1",
|
|
||||||
"@kwsites/promise-deferred": "^1.1.1",
|
|
||||||
"debug": "^4.3.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/sinon": {
|
"node_modules/sinon": {
|
||||||
"version": "11.1.2",
|
"version": "11.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz",
|
||||||
@ -17206,16 +17195,6 @@
|
|||||||
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==",
|
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"simple-git": {
|
|
||||||
"version": "2.45.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.45.0.tgz",
|
|
||||||
"integrity": "sha512-wu/Ujs9IXn0HuyYm4HyRvne+EKsjJSWKEMkB3wQa3gNHSMHt7y3oeNX9zRQ3UBPk7bRRMLLHAdIZCZfHT9ehPg==",
|
|
||||||
"requires": {
|
|
||||||
"@kwsites/file-exists": "^1.1.1",
|
|
||||||
"@kwsites/promise-deferred": "^1.1.1",
|
|
||||||
"debug": "^4.3.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"sinon": {
|
"sinon": {
|
||||||
"version": "11.1.2",
|
"version": "11.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz",
|
||||||
|
@ -82,7 +82,6 @@
|
|||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"node-ical": "^0.13.0",
|
"node-ical": "^0.13.0",
|
||||||
"simple-git": "^2.45.0",
|
|
||||||
"socket.io": "^4.1.3"
|
"socket.io": "^4.1.3"
|
||||||
},
|
},
|
||||||
"_moduleAliases": {
|
"_moduleAliases": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user