Skip to content

Commit

Permalink
Properly parse "Fixes:" (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Nov 3, 2017
1 parent e21cf5a commit 677bf31
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/links.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const FIXES_RE = /Fixes:\s*(\S+)/mg;
const FIX_RE = /Fixes:\s*(\S+)/;
const REFS_RE = /Refs?:\s*(\S+)/mg;
const REF_RE = /Refs?:\s*(\S+)/;
const FIXES_RE = /(Close[ds]?|Fix(e[ds])?|Resolve[sd]?)\s*:\s*(\S+)/mgi;
const FIX_RE = /(Close[ds]?|Fix(e[ds])?|Resolve[sd]?)\s*:\s*(\S+)/i;
const REFS_RE = /Refs?\s*:\s*(\S+)/mgi;
const REF_RE = /Refs?\s*:\s*(\S+)/i;
const { JSDOM } = require('jsdom');

/**
Expand All @@ -21,7 +21,7 @@ class LinkParser {
for (const item of arr) {
const m = item.match(FIX_RE);
if (!m) continue;
const fix = m[1];
const fix = m[3];
const url = fix.replace(/^#/, `${repo}#`).replace('#', '/issues/');
result.push(`https://github.com/${url}`);
}
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/op_html.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"<p>The npm install rules had a hidden dependency on the <code>node</code> binary<br>\ninstall rule creating the <code>$PREFIX/bin</code> directory.</p>\n<p>Because with <code>./configure --shared</code> no binary is created, the rule<br>\nsubsequently failed. Fix that by creating the directory before<br>\ncreating the symlinks to the npm and npx scripts.</p>\n<p>(Whether it makes sense to install npm without a <code>node</code> binary is<br>\na separate question. This commit is not taking positions. :-))</p>\n<p>Regression introduced in commit <a href=\"https://github.com/nodejs/node/commit/ed8c89a07d159b72a2e351a76c92b8b6a15515bd\" class=\"commit-link\"><tt>ed8c89a</tt></a> (\"build: fix shared installing<br>\ntarget\") which, as the commit log indicates, was itself a bug fix for<br>\nthe <code>./configure --shared</code> install.</p>\n<p>Fixes: <a href=\"https://github.com/nodejs/node/issues/16437\" class=\"issue-link js-issue-link\" data-error-text=\"Failed to load issue title\" data-id=\"267969588\" data-permission-text=\"Issue title is private\" data-url=\"https://github.com/nodejs/node/issues/16437\">#16437</a><br>\nRefs: <a href=\"https://github.com/nodejs/node/pull/15148\" class=\"issue-link js-issue-link\" data-error-text=\"Failed to load issue title\" data-id=\"254809069\" data-permission-text=\"Issue title is private\" data-url=\"https://github.com/nodejs/node/issues/15148\">#15148</a></p>",
"<p>Refs: <a href=\"https://github.com/nodejs/node/pull/16293\" class=\"issue-link js-issue-link\" data-error-text=\"Failed to load issue title\" data-id=\"266519190\" data-permission-text=\"Issue title is private\" data-url=\"https://github.com/nodejs/node/issues/16293\">#16293</a></p>\n<h5>Checklist</h5>\n\n<ul class=\"contains-task-list\">\n<li class=\"task-list-item\"><input checked=\"\" class=\"task-list-item-checkbox\" disabled=\"\" id=\"\" type=\"checkbox\"> <code>make -j4 test</code> (UNIX), or <code>vcbuild test</code> (Windows) passes</li>\n<li class=\"task-list-item\"><input checked=\"\" class=\"task-list-item-checkbox\" disabled=\"\" id=\"\" type=\"checkbox\"> commit message follows <a href=\"https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#commit-message-guidelines\">commit guidelines</a></li>\n</ul>\n<h5>Affected core subsystem(s)</h5>\n\n<p>vm</p>"
"<p>Refs: <a href=\"https://github.com/nodejs/node/pull/16293\" class=\"issue-link js-issue-link\" data-error-text=\"Failed to load issue title\" data-id=\"266519190\" data-permission-text=\"Issue title is private\" data-url=\"https://github.com/nodejs/node/issues/16293\">#16293</a></p>\n<h5>Checklist</h5>\n\n<ul class=\"contains-task-list\">\n<li class=\"task-list-item\"><input checked=\"\" class=\"task-list-item-checkbox\" disabled=\"\" id=\"\" type=\"checkbox\"> <code>make -j4 test</code> (UNIX), or <code>vcbuild test</code> (Windows) passes</li>\n<li class=\"task-list-item\"><input checked=\"\" class=\"task-list-item-checkbox\" disabled=\"\" id=\"\" type=\"checkbox\"> commit message follows <a href=\"https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#commit-message-guidelines\">commit guidelines</a></li>\n</ul>\n<h5>Affected core subsystem(s)</h5>\n\n<p>vm</p>",
"<p>Included reference to \\'constant time\\' in crypto.timingSafeEqual description</p>\n<p><span aria-label=\"This pull request closes issue #16504.\" class=\"issue-keyword tooltipped tooltipped-se\">Fixes</span> : <a href=\"https://github.com/nodejs/node/issues/16504\" class=\"issue-link js-issue-link\" data-error-text=\"Failed to load issue title\" data-id=\"268571876\" data-permission-text=\"Issue title is private\" data-url=\"https://github.com/nodejs/node/issues/16504\">#16504</a></p>"
]
7 changes: 5 additions & 2 deletions test/unit/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ const assert = require('assert');
const htmls = fixtures.readJSON('op_html.json');

const expected = [{
fixes: ['https://github.com/node/issues/16437'],
fixes: ['https://github.com/nodejs/node/issues/16437'],
refs: ['https://github.com/nodejs/node/pull/15148']
}, {
fixes: [],
refs: ['https://github.com/nodejs/node/pull/16293']
}, {
fixes: ['https://github.com/nodejs/node/issues/16504'],
refs: []
}];

describe('LinkParser', () => {
it('should parse fixes and refs', () => {
for (let i = 0; i < htmls.length; ++i) {
const op = htmls[i];
const parser = new LinkParser('node', op);
const parser = new LinkParser('nodejs/node', op);
const actual = {
fixes: parser.getFixes(),
refs: parser.getRefs()
Expand Down

0 comments on commit 677bf31

Please sign in to comment.