diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-06-23 15:11:44 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-06-23 15:11:44 +0200 |
commit | d3a21445ad2f70565d10f632aa9d522e190f9e00 (patch) | |
tree | bb2d112daddb98d8394e81b6f4712754fbed58ed | |
parent | 5f4a854cf9497d07745ebd9d4c65a3b954c494ec (diff) | |
download | bugzilla-triage-d3a21445ad2f70565d10f632aa9d522e190f9e00.tar.gz |
Fix timesheet generation with bad URLs and get activated on the Freedesktop bugzilla as well
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | lib/logger.js | 48 | ||||
-rw-r--r-- | lib/main.js | 1 | ||||
-rw-r--r-- | lib/util.js | 4 |
4 files changed, 30 insertions, 26 deletions
@@ -3,6 +3,3 @@ all: install install: rsync -avz jsons/RH_Data-packages.json \ /home/matej/Dokumenty/website/ceplovi.cz/matej/progs/data/ - -test: - cfx run -a firefox -P ~/.mozilla/firefox/zj3uh9ia.devel-SDK/ & diff --git a/lib/logger.js b/lib/logger.js index 01c626d..ecd7e27 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -84,28 +84,32 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) { var currentDay = ""; // now print the array tmpArr.forEach(function(rec) { - var x = rec[1]; - var dayStr = utilMod.getISODate(x.date); - var host = urlMod.URL(x.url).host; - var BZName = that.getBugzillaAbbr(x.url); - var bugNo = utilMod.getBugNo(x.url); - if (dayStr != currentDay) { - currentDay = dayStr; - body.innerHTML += "<hr/><p><strong>" + currentDay - + "</strong></p>"; - } - // replace "bug ####" with a hyperlink to the current bugzilla - var comment = x.comment.replace(commentBugRE, - "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>"); - body.innerHTML += "<p><em><a href='" - + x.url - + "'>Bug " - + BZName + "/" + bugNo + ": " - + x.title - + "</a>" - + " </em>\n<br/>" + comment + "</p>"; - }); -}; + var x = rec[1]; + var dayStr = utilMod.getISODate(x.date); + var host = urlMod.URL(x.url).host; + var BZName = that.getBugzillaAbbr(x.url); + var bugNo = utilMod.getBugNo(x.url); + // protection against misbehaving URLs + if (!bugNo) { + throw new Error("wrong record:\n" + rec.toSource() + "\n"); + } + if (dayStr != currentDay) { + currentDay = dayStr; + body.innerHTML += "<hr/><p><strong>" + currentDay + + "</strong></p>"; + } + // replace "bug ####" with a hyperlink to the current bugzilla + var comment = x.comment.replace(commentBugRE, + "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>"); + body.innerHTML += "<p><em><a href='" + + x.url + + "'>Bug " + + BZName + "/" + bugNo + ": " + + x.title + + "</a>" + + " </em>\n<br/>" + comment + "</p>"; + }); + }; /** * diff --git a/lib/main.js b/lib/main.js index e0a1fe0..7cd9a9c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,6 +26,7 @@ var config = {}; config.matches = [ "https://bugzilla.redhat.com/show_bug.cgi", "https://bz-web2-test.devel.redhat.com/show_bug.cgi", + "https://bugs.freedesktop.org/show_bug.cgi", "https://bugzilla.mozilla.org/show_bug.cgi" ]; diff --git a/lib/util.js b/lib/util.js index b165567..b2a093c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -36,15 +36,17 @@ exports.heir = function heir(p) { exports.getBugNo = function getBugNo(url) { + console.log("url = " + url); var re = new RegExp(".*id=([0-9]+).*$"); var bugNo = null; if (!url) { throw new Error("Missing URL value!"); } var reResult = re.exec(url); - if (reResult[1]) { + if (reResult && reResult[1]) { bugNo = reResult[1]; } + console.log("bugNo = " + bugNo); return bugNo; }; |