-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make fixes
and refs
detection stricter
#612
Conversation
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.
Codecov Report
@@ Coverage Diff @@
## main #612 +/- ##
=======================================
Coverage 84.10% 84.10%
=======================================
Files 37 37
Lines 4051 4051
=======================================
Hits 3407 3407
Misses 644 644
Continue to review full report at Codecov.
|
Co-authored-by: Tobias Nießen <[email protected]>
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By tolerating spaces at the start of the line, might this then match the "Fixes:" etc. in patches we float from V8 etc.? (Maybe that's not a problem?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for a separate PR, but I think we probably don't need to tolerate spaces before the colon:
const FIXES_RE = /^\s*(Close[ds]?|Fix(e[ds])?|Resolve[sd]?)\s*:\s*(\S+)/mgi; | |
const FIXES_RE = /^\s*(Close[ds]?|Fix(e[ds])?|Resolve[sd]?):\s*(\S+)/mgi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By tolerating spaces at the start of the line, might this then match the "Fixes:" etc. in patches we float from V8 etc.? (Maybe that's not a problem?)
Not sure. Maybe we need to find example PRs and run git node metadata
on them to see what they generate? We can do that on both open and closed PRs -- there will be an error about the PR not being landable but the output will still include the generated metadata.
It's entirely possible we may need stricter checking of the right hand side of the colon, but it's hard to speculate on that without more concrete examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found one. nodejs/node#37276 results in Fixes: https://github.com/v8:11389
(with and without this PR):
$ git node metadata 37276
✔ Done loading data for nodejs/node/pull/37276
----------------------------------- PR info ------------------------------------
Title deps: V8: workaround for darwin arm64 code page decommit failures (#37276)
⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch matinzd:patch-1 -> nodejs:master
Labels v8 engine, backported-to-v14.x
Commits 2
- deps: V8: Workaround MacOS 11.2 code page decommit failures
- bump: v8: v8_embedder_string to 25
Committers 2
- GitHub <[email protected]>
- matinzd <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/37276
Fixes: https://github.com/v8:11389
Refs: https://bugs.chromium.org/p/v8/issues/detail?id=11389#c18
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ash Cripps <[email protected]>
--------------------------------------------------------------------------------
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just noticed that for PR-URL we have a different parsing scheme that pulls the links out of the corresponding anchor tag (the parser is parsing HTML). Maybe we should be reusing that logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reusing the same logic that is used for refs
and PR-URL
seems a better solution. Or at least a more consistent one. PR: #614
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for a separate PR, but I think we probably don't need to tolerate spaces before the colon:
const REFS_RE = /^\s*Refs?\s*:\s*(\S+)/mgi; | |
const REFS_RE = /^\s*Refs?:\s*(\S+)/mgi; |
Closing in favour of #614 |
Only parse
fixes
andrefs
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.
Refs: nodejs/node#42382 (comment)
cc @Trott
I have updated one of the existing test cases as otherwise the test was failing with this change. This test was from #117, for nodejs/node#17107. I ran
node ../node-core-utils/bin/get-metadata.js 17107
with this diff:and found the HTML differs from what is in the test fixture, so I updated it. The test passes was the updated HTML. I used the same diff to capture the test data for nodejs/node#42382.