{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments/26792063","id":26792063,"diff_hunk":"@@ -40,22 +40,39 @@ treeherder.filter('stripHtml', function() {\n treeherder.filter('linkifyBugs', function() {\n     return function(input) {\n         var str = input || '';\n-        var bug_matches = /.*-- ([0-9]+)|.*bug-([0-9]+)|.*Bug ([0-9]+)/ig.exec(str);\n-        var pr_matches = /PR#([0-9]+)/i.exec(str);\n         var clear_attr = 'ignore-job-clear-on-click';\n-        if (pr_matches) {\n-            var pr_url = \"https://github.com/mozilla-b2g/gaia/pull/\" + pr_matches[1];\n-            var pr_hyperlink = '<a href=\"' + pr_url + '\" ' + clear_attr + '>' +\n-                               pr_matches[1] + '</a>';\n-            str = str.replace(pr_matches[1], pr_hyperlink);\n-        }\n+\n+        // Test strings\n+        // var str = \"No bugs\";\n+        // var str = \"One bug 1130488\";\n+        // var str = \"One PR#456\";\n+        // var str = \"Bug 1130488 disable tests for bug 999 and -- 777 and PR#368 and PR#456\";\n+        var str = \"Bug 1130488 Bug 1130488 bug 1130488 -- 777 and pr#368 and PR#456\";\n+\n+        var bug_matches = str.match(/-- ([0-9]+)|bug.([0-9]+)/ig);\n+        var pr_matches = str.match(/PR#([0-9]+)/ig);\n+\n+        // Settings\n+        var bug_title = 'bugzilla.mozilla.org';\n+        var bug_url = '<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=$1\" ' +\n+            'data-bugid=$1 ' + 'title=' + bug_title + '>$1</a>';\n+        var pr_title = 'github.com';\n+        var pr_url = '<a href=\"https://github.com/mozilla-b2g/gaia/pull/$1\" ' +\n+            'data-prid=$1 ' + 'title=' + pr_title + '>$1</a>';\n+\n         if (bug_matches) {\n-            var bug_match = bug_matches[1] || bug_matches[2] || bug_matches[3];\n-            var bug_url = \"https://bugzilla.mozilla.org/show_bug.cgi?id=\" + bug_match;\n-            var bug_hyperlink = '<a href=\"' + bug_url + '\" ' + clear_attr + '>' +\n-                                bug_match + '</a>';\n-            str = str.replace(bug_match, bug_hyperlink);\n+            // Separate passes to preserve prefix\n+            var str = str.replace(/Bug ([0-9]+)/g, \"Bug \" + bug_url);\n+            var str = str.replace(/bug ([0-9]+)/g, \"bug \" + bug_url);\n+            var str = str.replace(/-- ([0-9]+)/g, \"-- \" + bug_url);","path":"webapp/app/js/filters.js","position":41,"original_position":41,"commit_id":"0b36e7dd861158994ca8637f1c31a7ad016c62ad","original_commit_id":"0b36e7dd861158994ca8637f1c31a7ad016c62ad","user":{"login":"tojonmz","id":3660661,"avatar_url":"https://avatars.githubusercontent.com/u/3660661?v=3","gravatar_id":"","url":"https://api.github.com/users/tojonmz","html_url":"https://github.com/tojonmz","followers_url":"https://api.github.com/users/tojonmz/followers","following_url":"https://api.github.com/users/tojonmz/following{/other_user}","gists_url":"https://api.github.com/users/tojonmz/gists{/gist_id}","starred_url":"https://api.github.com/users/tojonmz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tojonmz/subscriptions","organizations_url":"https://api.github.com/users/tojonmz/orgs","repos_url":"https://api.github.com/users/tojonmz/repos","events_url":"https://api.github.com/users/tojonmz/events{/privacy}","received_events_url":"https://api.github.com/users/tojonmz/received_events","type":"User","site_admin":false},"body":"Gah, yes. Of course.","created_at":"2015-03-19T20:04:36Z","updated_at":"2015-03-19T20:04:36Z","html_url":"https://github.com/mozilla/treeherder-ui/pull/430#discussion_r26792063","pull_request_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430","_links":{"self":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments/26792063"},"html":{"href":"https://github.com/mozilla/treeherder-ui/pull/430#discussion_r26792063"},"pull_request":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430","id":31556938,"html_url":"https://github.com/mozilla/treeherder-ui/pull/430","diff_url":"https://github.com/mozilla/treeherder-ui/pull/430.diff","patch_url":"https://github.com/mozilla/treeherder-ui/pull/430.patch","issue_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/430","number":430,"state":"open","locked":false,"title":"Bug 1133021 - Linkify all bugs and prs in revision commit messages - do not merge","user":{"login":"tojonmz","id":3660661,"avatar_url":"https://avatars.githubusercontent.com/u/3660661?v=3","gravatar_id":"","url":"https://api.github.com/users/tojonmz","html_url":"https://github.com/tojonmz","followers_url":"https://api.github.com/users/tojonmz/followers","following_url":"https://api.github.com/users/tojonmz/following{/other_user}","gists_url":"https://api.github.com/users/tojonmz/gists{/gist_id}","starred_url":"https://api.github.com/users/tojonmz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tojonmz/subscriptions","organizations_url":"https://api.github.com/users/tojonmz/orgs","repos_url":"https://api.github.com/users/tojonmz/repos","events_url":"https://api.github.com/users/tojonmz/events{/privacy}","received_events_url":"https://api.github.com/users/tojonmz/received_events","type":"User","site_admin":false},"body":"This work fixes Bugzilla bug [1133021](https://bugzilla.mozilla.org/show_bug.cgi?id=1133021).\r\n\r\nThis linkifies all bugs and pull requests in a given commit message that match the following prefixes:\r\n\r\n* \"Bug \", \"bug \", \"-- \"\r\n* \"PR#\" \"pr#\"\r\n\r\nHere's the before with an example test case (note also the commit-title populating the bug/pr links):\r\n\r\n![commitlinkscurrent](https://cloud.githubusercontent.com/assets/3660661/6737868/ce23efa2-ce44-11e4-8eb3-d32daeaa60f2.jpg)\r\n\r\nHere's the after:\r\n\r\n![commitlinksproposed](https://cloud.githubusercontent.com/assets/3660661/6737884/e280880c-ce44-11e4-96e5-d16a208b9cf8.jpg)\r\n\r\nI've tested a variety of different messages (no bugs, single bugs/prs, multiple bugs/prs, identical bugs/prs, identically-prefixed bugs/prs, the originally reported bug revision ) and everything seems to be ok.\r\n\r\nI tried a bunch of different implementations: loops, a function with passed params, doing the replace in one shot (problematic with \"-- \" and the $n param in the url vars), specifying the .replace string as a [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter) which also doesn't seem compatible with $n use.\r\n\r\nSo instead we just check if we have pr or bug match, and do a separate pass for each case. We incur minor cost, but probably no more than if we tested for conditions.\r\n\r\nWe now inject a generic bmo/github title for each issue type. The overall span retains its own tooltip commit summary on hover. Initially I did it to avoid a bmo/github API to get the \"Summary\", which was outside the scope of the bug anyway. I think a generic title makes more sense. It tells the user what the link is, and doesn't confuse them with what could be a very similar tooltip to the commit span.\r\n\r\nI've left some test values in this initial commit for testing, which I will remove prior to merge. Everything appears to be ok on both Firefox and Chrome. Please beat it up as much as possible and with other commit message sequences :)\r\n\r\nTested on OSX 10.9.5:\r\nFF Release **36.0.1**\r\nChrome Latest Release **41.0.2272.89** (64-bit)\r\n\r\nAdding @wlach for review/branch testing, and @edmorley for visibility.","created_at":"2015-03-19T19:22:54Z","updated_at":"2015-03-19T20:04:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a14d25516e71373bd18e821b3ca230345f06cc63","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430/commits","review_comments_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430/comments","review_comment_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/430/comments","statuses_url":"https://api.github.com/repos/mozilla/treeherder-ui/statuses/0b36e7dd861158994ca8637f1c31a7ad016c62ad","head":{"label":"tojonmz:commit-msg-links","ref":"commit-msg-links","sha":"0b36e7dd861158994ca8637f1c31a7ad016c62ad","user":{"login":"tojonmz","id":3660661,"avatar_url":"https://avatars.githubusercontent.com/u/3660661?v=3","gravatar_id":"","url":"https://api.github.com/users/tojonmz","html_url":"https://github.com/tojonmz","followers_url":"https://api.github.com/users/tojonmz/followers","following_url":"https://api.github.com/users/tojonmz/following{/other_user}","gists_url":"https://api.github.com/users/tojonmz/gists{/gist_id}","starred_url":"https://api.github.com/users/tojonmz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tojonmz/subscriptions","organizations_url":"https://api.github.com/users/tojonmz/orgs","repos_url":"https://api.github.com/users/tojonmz/repos","events_url":"https://api.github.com/users/tojonmz/events{/privacy}","received_events_url":"https://api.github.com/users/tojonmz/received_events","type":"User","site_admin":false},"repo":{"id":21174887,"name":"treeherder-ui","full_name":"tojonmz/treeherder-ui","owner":{"login":"tojonmz","id":3660661,"avatar_url":"https://avatars.githubusercontent.com/u/3660661?v=3","gravatar_id":"","url":"https://api.github.com/users/tojonmz","html_url":"https://github.com/tojonmz","followers_url":"https://api.github.com/users/tojonmz/followers","following_url":"https://api.github.com/users/tojonmz/following{/other_user}","gists_url":"https://api.github.com/users/tojonmz/gists{/gist_id}","starred_url":"https://api.github.com/users/tojonmz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tojonmz/subscriptions","organizations_url":"https://api.github.com/users/tojonmz/orgs","repos_url":"https://api.github.com/users/tojonmz/repos","events_url":"https://api.github.com/users/tojonmz/events{/privacy}","received_events_url":"https://api.github.com/users/tojonmz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tojonmz/treeherder-ui","description":"The UI for treeherder, a replacement for TBPL.","fork":true,"url":"https://api.github.com/repos/tojonmz/treeherder-ui","forks_url":"https://api.github.com/repos/tojonmz/treeherder-ui/forks","keys_url":"https://api.github.com/repos/tojonmz/treeherder-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tojonmz/treeherder-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tojonmz/treeherder-ui/teams","hooks_url":"https://api.github.com/repos/tojonmz/treeherder-ui/hooks","issue_events_url":"https://api.github.com/repos/tojonmz/treeherder-ui/issues/events{/number}","events_url":"https://api.github.com/repos/tojonmz/treeherder-ui/events","assignees_url":"https://api.github.com/repos/tojonmz/treeherder-ui/assignees{/user}","branches_url":"https://api.github.com/repos/tojonmz/treeherder-ui/branches{/branch}","tags_url":"https://api.github.com/repos/tojonmz/treeherder-ui/tags","blobs_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tojonmz/treeherder-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/tojonmz/treeherder-ui/languages","stargazers_url":"https://api.github.com/repos/tojonmz/treeherder-ui/stargazers","contributors_url":"https://api.github.com/repos/tojonmz/treeherder-ui/contributors","subscribers_url":"https://api.github.com/repos/tojonmz/treeherder-ui/subscribers","subscription_url":"https://api.github.com/repos/tojonmz/treeherder-ui/subscription","commits_url":"https://api.github.com/repos/tojonmz/treeherder-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/tojonmz/treeherder-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/tojonmz/treeherder-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/tojonmz/treeherder-ui/contents/{+path}","compare_url":"https://api.github.com/repos/tojonmz/treeherder-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tojonmz/treeherder-ui/merges","archive_url":"https://api.github.com/repos/tojonmz/treeherder-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tojonmz/treeherder-ui/downloads","issues_url":"https://api.github.com/repos/tojonmz/treeherder-ui/issues{/number}","pulls_url":"https://api.github.com/repos/tojonmz/treeherder-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/tojonmz/treeherder-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/tojonmz/treeherder-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tojonmz/treeherder-ui/labels{/name}","releases_url":"https://api.github.com/repos/tojonmz/treeherder-ui/releases{/id}","created_at":"2014-06-24T17:50:28Z","updated_at":"2014-07-02T19:19:10Z","pushed_at":"2015-03-19T19:07:24Z","git_url":"git://github.com/tojonmz/treeherder-ui.git","ssh_url":"git@github.com:tojonmz/treeherder-ui.git","clone_url":"https://github.com/tojonmz/treeherder-ui.git","svn_url":"https://github.com/tojonmz/treeherder-ui","homepage":"https://wiki.mozilla.org/Auto-tools/Projects/Treeherder","size":13233,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"b437d020d6355fcd70310aecf49dabf0ddd0dbdc","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":10973059,"name":"treeherder-ui","full_name":"mozilla/treeherder-ui","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/treeherder-ui","description":"The UI for treeherder, a replacement for TBPL. See wiki page for where to file bugs.","fork":false,"url":"https://api.github.com/repos/mozilla/treeherder-ui","forks_url":"https://api.github.com/repos/mozilla/treeherder-ui/forks","keys_url":"https://api.github.com/repos/mozilla/treeherder-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/treeherder-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/treeherder-ui/teams","hooks_url":"https://api.github.com/repos/mozilla/treeherder-ui/hooks","issue_events_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/treeherder-ui/events","assignees_url":"https://api.github.com/repos/mozilla/treeherder-ui/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/treeherder-ui/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/treeherder-ui/tags","blobs_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/treeherder-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/treeherder-ui/languages","stargazers_url":"https://api.github.com/repos/mozilla/treeherder-ui/stargazers","contributors_url":"https://api.github.com/repos/mozilla/treeherder-ui/contributors","subscribers_url":"https://api.github.com/repos/mozilla/treeherder-ui/subscribers","subscription_url":"https://api.github.com/repos/mozilla/treeherder-ui/subscription","commits_url":"https://api.github.com/repos/mozilla/treeherder-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/treeherder-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/treeherder-ui/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/treeherder-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/treeherder-ui/merges","archive_url":"https://api.github.com/repos/mozilla/treeherder-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/treeherder-ui/downloads","issues_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/treeherder-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/treeherder-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/treeherder-ui/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/treeherder-ui/releases{/id}","created_at":"2013-06-26T16:25:19Z","updated_at":"2015-03-19T19:18:56Z","pushed_at":"2015-03-19T19:18:55Z","git_url":"git://github.com/mozilla/treeherder-ui.git","ssh_url":"git@github.com:mozilla/treeherder-ui.git","clone_url":"https://github.com/mozilla/treeherder-ui.git","svn_url":"https://github.com/mozilla/treeherder-ui","homepage":"https://wiki.mozilla.org/Auto-tools/Projects/Treeherder","size":17930,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":4,"forks":35,"open_issues":4,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430"},"html":{"href":"https://github.com/mozilla/treeherder-ui/pull/430"},"issue":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/issues/430"},"comments":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/issues/430/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/430/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/statuses/0b36e7dd861158994ca8637f1c31a7ad016c62ad"}}}}