-
Notifications
You must be signed in to change notification settings - Fork 13
Improve Github keyword matching #674
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
Improve Github keyword matching #674
Conversation
No linked issues found. Please add the corresponding issues in the pull request description. |
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.
Pull Request Overview
This PR updates issue-reference extraction to support an optional colon and flexible spacing after GitHub keywords.
- Broaden
extractLocalIssues
andextractExternalIssues
regex patterns to allow a colon and extra whitespace before the issue number or URL - Adjust mock data in tests to include cases with colons and varied spaces
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/util.js | Updated both extractLocalIssues and extractExternalIssues regexes |
mocks/@actions/github.js | Modified mock PR bodies to include colon variants and extra whitespace |
Comments suppressed due to low confidence (2)
src/util.js:137
- Same issue in the external-issues regex:
(?:\s*:)?
won’t match a colon directly after the keyword. Switch to(?::)?
to cover bothcloses:
andcloses :
cases.
/\b(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)(?:\s*:)?\s+(https?:\/\/github\.com\/)*.../gim;
src/util.js:121
- Add unit tests covering cases with no-space colon (e.g.,
fixes:#123
), colon with space (e.g.,fixes: #123
), and without a colon (e.g.,fixes #123
) to confirm the updated regex handles all variants.
function extractLocalIssues(body) {
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.
Can you please create new test cases instead of modifying existing ones?
Github allows additional spacing and a single colon character between the Github keyword and the issue number.
4fe395a
to
73751dc
Compare
@simoneb not sure why, that would involve a lot more effort. The current tests are fine, just the mocked data is slightly adjusted to also test the more lenient syntax, along with the existing syntax. |
@gstokkink I'm testing your modified regexp for local issues but I can't seem to make it match what you suggest should be matching, e.g. the double spaces. Is this scenario intended to be handled? |
@simoneb interesting, that should match as well. I'd expect the |
@gstokkink having specific tests for the new format may help, because I'm confused as well. Reading the new regexp you wrote, it makes sense to me, but then the test I did doesn't work, so I hope that tests will clarify this. We should consider testing the regexp matching functions in isolation. |
@simoneb ah, I see your mistake. You added the |
@simoneb Thanks for merging! Can we get a new release as well? 😄 Edit: cheers! |
Github allows additional spacing and a single colon character between the Github keyword and the issue number.