aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-23 15:11:44 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-23 15:11:44 +0200
commitd3a21445ad2f70565d10f632aa9d522e190f9e00 (patch)
treebb2d112daddb98d8394e81b6f4712754fbed58ed
parent5f4a854cf9497d07745ebd9d4c65a3b954c494ec (diff)
downloadbugzilla-triage-d3a21445ad2f70565d10f632aa9d522e190f9e00.tar.gz
Fix timesheet generation with bad URLs and get activated on the Freedesktop bugzilla as well
-rw-r--r--Makefile3
-rw-r--r--lib/logger.js48
-rw-r--r--lib/main.js1
-rw-r--r--lib/util.js4
4 files changed, 30 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index e95c52d..e2ffc0d 100644
--- a/Makefile
+++ b/Makefile
@@ -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;
};