Skip to content
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: potential non-url Fixes being added to metadata #485

Closed
wants to merge 2 commits into from

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Aug 19, 2020

Closes #233.

Filters out anything from being added to Fixes metadata that does not look e.g like:

Fixes #16
Fixes nodejs/build#1961
Fixes https://github.com/nodejs/node/issue/12345

@codebytere codebytere requested a review from a team August 19, 2020 06:48
@codebytere codebytere changed the title fix: potential non-url fixes fix: potential non-url Fixes being added to metadata Aug 19, 2020
@codecov
Copy link

codecov bot commented Aug 19, 2020

Codecov Report

Merging #485 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #485      +/-   ##
==========================================
+ Coverage   82.59%   82.60%   +0.01%     
==========================================
  Files          34       34              
  Lines        1660     1661       +1     
==========================================
+ Hits         1371     1372       +1     
  Misses        289      289              
Impacted Files Coverage Δ
lib/links.js 88.88% <100.00%> (+0.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de6d1e2...44ad7cf. Read the comment docs.

@richardlau
Copy link
Member

Would it still allow URLs?

@joyeecheung
Copy link
Member

From what I can tell this would make links like Fixes: https://github.com/nodejs/node/issue/12345 invalid?

@codebytere
Copy link
Member Author

Missed a spot in the regex - should be fixed up now!

@mmarchini
Copy link
Contributor

The goal lgtm, would need more time to review the regex (if others think the regex is fine I'm good with it too!)

@richardlau
Copy link
Member

Tests would be good. Particularly one showing an example of a non-url Fixes being ignored and one showing a Fixes with a full URL is accepted.

@@ -5,6 +5,8 @@ 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 PR_RE = /PR-URL\s*:\s*(\S+)/i;
const LINK_RE = /(#?\d+)|(\S+\/\S+(\/#?|\/?)\d+)/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches just numbers (first clause), is that right as I don't think it's a valid GitHub Fixes value?
Also, this allows for something like some-text.../12345.

Could I suggest something like

^(#\d+|[^\s/]+\/[^\s/]+#\d+|https?:\/\/github\.com\/[^\s/]+\/[^\s/]+\/(issue|pull)\/\d+)$
     ^                ^                                                         ^
  handle       |   handle      |              handle http(s)://github.com/<any>/<any>/issue
 same-repo     |   GitHub      |              or pull/issue pr number
 shorthand     |  shorthand    |

The [^\s/] can be simplified to \w if we don't care about unicode names.

testing link https://regex101.com/r/JCwzau/1, there are a few unit-tests as well

Copy link
Member Author

@codebytere codebytere Aug 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lundibundi I do agree it could be more robust - i'm happy to swap to this one :D

@github-actions
Copy link
Contributor

This PR is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@github-actions github-actions bot added the stale label Nov 21, 2020
@codebytere codebytere closed this Nov 23, 2020
@codebytere codebytere deleted the improve-fixes-regex branch November 23, 2020 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants