diff --git a/modules/default/updatenotification/node_helper.js b/modules/default/updatenotification/node_helper.js index 6196552f..df989faa 100644 --- a/modules/default/updatenotification/node_helper.js +++ b/modules/default/updatenotification/node_helper.js @@ -64,7 +64,10 @@ module.exports = NodeHelper.create({ sg.git.fetch().status(function(err, data) { data.module = sg.module; if (!err) { - self.sendSocketNotification("STATUS", data); + sg.git.log({"-1": null}, function(err, data2) { + data.hash = data2.latest.hash; + self.sendSocketNotification("STATUS", data); + }); } }); }); diff --git a/modules/default/updatenotification/updatenotification.js b/modules/default/updatenotification/updatenotification.js index bf7ec2c1..306ac6ae 100644 --- a/modules/default/updatenotification/updatenotification.js +++ b/modules/default/updatenotification/updatenotification.js @@ -34,6 +34,17 @@ Module.register("updatenotification", { } }, + diffLink: function(text) { + var localRef = this.status.hash; + var remoteRef = this.status.tracking.replace(/.*\//, ""); + return "" + + text + + ""; + }, + // Override dom generator. getDom: function () { var wrapper = document.createElement("div"); @@ -47,9 +58,14 @@ Module.register("updatenotification", { icon.innerHTML = " "; message.appendChild(icon); + var subtextHtml = this.translate("UPDATE_INFO") + .replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits")) + .replace("BRANCH_NAME", this.status.current); + var text = document.createElement("span"); if (this.status.module == "default") { text.innerHTML = this.translate("UPDATE_NOTIFICATION"); + subtextHtml = this.diffLink(subtextHtml); } else { text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE").replace("MODULE_NAME", this.status.module); } @@ -58,9 +74,7 @@ Module.register("updatenotification", { wrapper.appendChild(message); var subtext = document.createElement("div"); - subtext.innerHTML = this.translate("UPDATE_INFO") - .replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits")) - .replace("BRANCH_NAME", this.status.current); + subtext.innerHTML = subtextHtml; subtext.className = "xsmall dimmed"; wrapper.appendChild(subtext); }