bugzilla-linkify "bug X comment Y" to comment anchor



Other Applications
10 years ago
9 years ago


(Reporter: Tuukka Tolvanen (sp3000), Assigned: James Ross)


Firefox Tracking Flags

(Not tracked)


(Whiteboard: [cz-0.9.80])


(1 attachment)



10 years ago
would be nice to linkify "bug X comment Y" to e.g. https://bugzilla.mozilla.org/show_bug.cgi?id=X#cY


10 years ago
OS: Linux → All
Hardware: PC → All
Version: unspecified → Trunk
Bugzilla trunk and b.m.o already do this...


bug 406777 comment 0.
Wow, I completely ignored what product this was filed against and assumed it was Bugzilla. Ignore my previous comment!

Comment 3

10 years ago
Created attachment 292261 [details] [diff] [review]
Link bug XXX comment YYY

I decided to be a little clever with this. Rather than always have a suffix or a completely separate URL for comments, it supports both. The preference bugURL.comment can be a full URL (with %1$s + %2$s) or a suffix (with %s) for the main bugURL preference. It defaults to the correct suffix for Bugzillas.
Assignee: rginda → silver
Attachment #292261 - Flags: review?(gijskruitbosch+bugs)

Comment 4

10 years ago
Comment on attachment 292261 [details] [diff] [review]
Link bug XXX comment YYY

>Index: locales/en-US/chrome/chatzilla.properties
>-pref.bugURL.help                = The URL used for links to bugs, with "%s" replaced with the bug number. The text "bug " followed by a number will get turned into a link using this URL.
>+pref.bugURL.help                = The URL used for links to bugs. "%s" is replaced with the bug number. The text "bug " followed by a number will get turned into a link using this URL.
>+pref.bugURL.comment.label       = Bugzilla URL for Comments
>+pref.bugURL.comment.help        = The URL or suffix used for links to specific comments within bugs. With a full URL, "%1$s" and "%2$s" are replaced with the bug and comment numbers, respectively. With a suffix, "%s" is replaced with the comment number. The text "bug " followed by a number followed by " comment " followed by another number will get turned into a link using this URL or suffix.

These help strings are no longer correct: bug #czpluginapi works too. Please make the help strings reflect that.

>Index: xul/content/mungers.js
>RCS file: /cvsroot/mozilla/extensions/irc/xul/content/mungers.js,v
>retrieving revision 1.10
>diff -d -p -u -6 -r1.10 mungers.js
>--- xul/content/mungers.js	4 Sep 2007 08:52:24 -0000	1.10
>+++ xul/content/mungers.js	9 Dec 2007 00:50:00 -0000
>@@ -96,13 +96,13 @@ function initMunger()
>     // This has a higher starting priority so as to get it to match before the
>     // normal link, which won't know about mailto and then fail.
>     munger.addRule(".mailto",
>        /(?:\s|\W|^)((mailto:)?[^:;\\<>\[\]()\'\"\s\u201d]+@[^.<>\[\]()\'\"\s\u201d]+\.[^<>\[\]()\'\"\s\u201d]+)/i,
>                    insertMailToLink, NORMAL_PRIORITY, HIGHER_PRIORITY, false);
>     munger.addRule("bugzilla-link",
>-                   /(?:\s|\W|^)(bug\s+(?:#?\d+|#[^\s,]{1,20}))/i,
>+                   /(?:\s|\W|^)(bug\s+(?:#?\d+|#[^\s,]{1,20})(\s+comment\s+(?:#?\d+|#[^\s,]{1,5}))?)/i,

You're allowing a named comment here? Does bugzilla do that, or some other bug tracking system? Can you give an example?

>@@ -343,26 +343,57 @@ function insertBugzillaLink (matchText, 
>         client.munger.munge(matchText, containerTag, eventData);
>         mungerEntry.enabled = true;
>         return;
>     }
>     var bugURL;
>+    var bugURLcomment;
>     if (eventData.channel)
>+    {
>         bugURL = eventData.channel.prefs["bugURL"];
>+        bugURLcomment = eventData.channel.prefs["bugURL.comment"];
>+    }
>     else if (eventData.network)
>+    {
>         bugURL = eventData.network.prefs["bugURL"];
>+        bugURLcomment = eventData.network.prefs["bugURL.comment"];
>+    }
>     else
>+    {
>         bugURL = client.prefs["bugURL"];
>+        bugURLcomment = client.prefs["bugURL.comment"];
>+    }

This could be more elegant by setting an interim variable to the right prefs object, eliminating the need for braces, and then setting bugURL and bugURLcomment just once, from the right prefs object.

>     if (bugURL.length > 0)
>     {
>         var idOrAlias = matchText.match(/bug\s+#?(\d+|[^\s,]{1,20})/i)[1];
>+        bugURL = bugURL.replace("%s", idOrAlias);
>+        if (matchText.indexOf("comment") != -1)
>+        {
>+            var commentNum = matchText.match(/comment\s+#?(\d+|[^\s,]{1,5})/i)[1];

If you go and remove support for named comments, please remember to update this regex as well.

> <snip>

r=me with the above fixed and/or explained. :-)
Attachment #292261 - Flags: review?(gijskruitbosch+bugs) → review+

Comment 5

10 years ago
Checked in with fixes --> FIXED.
Last Resolved: 10 years ago
Resolution: --- → FIXED
Whiteboard: [cz-0.9.80]

Comment 6

9 years ago
v ChatZilla
You need to log in before you can comment on or make changes to this bug.