-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow other options to enter pr #55
Conversation
I could have made the regex patterns a single pattern, but it became extremely hard to read so I kept them seperate |
src/commands/ptal.ts
Outdated
pathSections.shift(); | ||
if(githubURL.hostname != "github.com" || pathSections.length != 4 || pathSections[2] != "pull" || !Number.parseInt(pathSections[3])) | ||
const githubRE = /https:\/\/github\.com\/(?<ORGANISATION>[^\/]+)\/(?<REPOSITORY>[^\/]+)\/pull\/(?<NUMBER>\d+)/; | ||
const otherRE = /((?<ORGANISATION>[^\/]+)\/)?(?<REPOSITORY>[^(#|\s)]+)(#|\s)(?<NUMBER>\d+)/; |
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.
In the second regex, it may be worth to also match /<org?>/<repo?>/pull/<number>
as well, because currently the options are either a full URL or /<org?>/<repo?>#<number>
The latter doesn't actually resolve in github (except #<number>
inline, but that only works for a single repo)
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.
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 had made both "https://" and "https://github.com/" optional so that should work now. I have removed the optional whitespace between the number and the repo. No clue why I added that
repo, | ||
pull_number | ||
owner: groups["ORGANISATION"] ?? "withastro", | ||
repo: groups["REPOSITORY"], |
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.
No default repository, but it is optional in otherRE
(Is it meant to be optional in otherRE
? I would have expected for #123
to resolve to withastro/astro/pulls/123
but maybe that was not the intention?)
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 don’t believe it’s optional in otherRE
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 see, / 123
and similar matched the regex so I thought maybe it was meant to be, but looking again that is most likely not intentional.
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.
In that case it could be quite handy to add a list of allowed "syntaxes" to the bot message
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 see,
/ 123
and similar matched the regex so I thought maybe it was meant to be, but looking again that is most likely not intentional.
Yeah. I’m guessing that it matches the repo name as “/“ in that case
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.
My comment on the other review also addresses this issue
With those few regex tweaks otherwise LGTM |
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.
This LGTM!
Not blocking, but I found the nested if((match = githubOption.match(githubRE)) == null)
quite difficult to read. Suggested a simplification that makes the logic easier to follow.
Parsing now supports:
https://github.com/withastro/houston-bot/pull/52
withastro/houston-bot#52
houston-bot#52
Also resolves a crash when an invalid deployment or other URL is provided