From 5389a25dcb6236da0120407b3bcc0ddda4bcf8b8 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Sat, 19 Mar 2022 09:58:49 -0400 Subject: [PATCH 1/2] fix: make `fixes` and `refs` detection stricter Only parse `fixes` and `refs` links at the beginning of lines. Previously the parser was picking up the "fix" type Conventional Commits titles from the changelog in body of the npm update pull requests. --- lib/links.js | 4 ++-- test/fixtures/op_html.json | 3 ++- test/unit/links.test.js | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/links.js b/lib/links.js index ad498b8a..4d313a16 100644 --- a/lib/links.js +++ b/lib/links.js @@ -1,8 +1,8 @@ import cheerio from 'cheerio'; -const FIXES_RE = /(Close[ds]?|Fix(e[ds])?|Resolve[sd]?)\s*:\s*(\S+)/mgi; +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 REFS_RE = /^Refs?\s*:\s*(\S+)/mgi; const REF_RE = /Refs?\s*:\s*(\S+)/i; const PR_RE = /PR-URL\s*:\s*(\S+)/i; diff --git a/test/fixtures/op_html.json b/test/fixtures/op_html.json index 3b604565..784eb6d4 100644 --- a/test/fixtures/op_html.json +++ b/test/fixtures/op_html.json @@ -2,5 +2,6 @@ "

The npm install rules had a hidden dependency on the node binary
\ninstall rule creating the $PREFIX/bin directory.

\n

Because with ./configure --shared no binary is created, the rule
\nsubsequently failed. Fix that by creating the directory before
\ncreating the symlinks to the npm and npx scripts.

\n

(Whether it makes sense to install npm without a node binary is
\na separate question. This commit is not taking positions. :-))

\n

Regression introduced in commit ed8c89a (\"build: fix shared installing
\ntarget\") which, as the commit log indicates, was itself a bug fix for
\nthe ./configure --shared install.

\n

Fixes: #16437
\nRefs: #15148

", "

Refs: #16293

\n
Checklist
\n\n\n
Affected core subsystem(s)
\n\n

vm

", "

Included reference to \\'constant time\\' in crypto.timingSafeEqual description

\n

Fixes : #16504

", - "
Checklist
Affected core subsystem(s)

doc, dgram

Refs: https://en.wikipedia.org/w/index.php?title=IPv6_address&type=revision&diff=809494791&oldid=804196124

" + "
Checklist
\n\n
Affected core subsystem(s)
\n

doc, dgram

\n

Refs: https://en.wikipedia.org/w/index.php?title=IPv6_address&type=revision&diff=809494791&oldid=804196124

", + "

v8.5.5 (2022-03-17)

\n

Bug Fixes

\n\n

Documentation

\n\n

Dependencies

\n" ] diff --git a/test/unit/links.test.js b/test/unit/links.test.js index f95ddcd5..6c281b64 100644 --- a/test/unit/links.test.js +++ b/test/unit/links.test.js @@ -18,8 +18,15 @@ describe('LinkParser', () => { fixes: ['https://github.com/nodejs/node/issues/16504'], refs: [] }, { + // Parse non-GitHub refs. + // https://github.com/nodejs/node/pull/17107 fixes: [], refs: ['https://en.wikipedia.org/w/index.php?title=IPv6_address&type=revision&diff=809494791&oldid=804196124'] + }, { + // Parse npm update pull requests. + // https://github.com/nodejs/node/pull/42382 + fixes: [], + refs: [] }]; for (let i = 0; i < htmls.length; ++i) { From 5da9c55d568ee515e4e6828ff181049ac5066fd5 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Sat, 19 Mar 2022 16:56:15 +0000 Subject: [PATCH 2/2] fixup! fix: make `fixes` and `refs` detection stricter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tobias Nießen --- lib/links.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/links.js b/lib/links.js index 4d313a16..91d06fe2 100644 --- a/lib/links.js +++ b/lib/links.js @@ -1,8 +1,8 @@ import cheerio from 'cheerio'; -const FIXES_RE = /^(Close[ds]?|Fix(e[ds])?|Resolve[sd]?)\s*:\s*(\S+)/mgi; +const FIXES_RE = /^\s*(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 REFS_RE = /^\s*Refs?\s*:\s*(\S+)/mgi; const REF_RE = /Refs?\s*:\s*(\S+)/i; const PR_RE = /PR-URL\s*:\s*(\S+)/i;