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

Match commands against each line #31

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

jakebailey
Copy link
Member

Currently, we match each command regex against the entire body; this means that each command can only execute once. That means that we can't ask the bot to do two of the same task, e.g. run two different perf runs with different arguments. Example: microsoft/TypeScript#55267 (comment)

Instead, split the body by lines, dedupe, then check each command against each of them, allowing each command to run more than once on the same body.

const botCall = "@typescript-bot";
for (const [key, value] of [...commands.entries()]) {
commands.delete(key);
commands.set(new RegExp(`${botCall} ${key.source}`, "i"), value);
Copy link
Member Author

Choose a reason for hiding this comment

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

I feel like this should be ^${botCall} but it's not a change in logic to keep it this way, I guess.

@@ -522,6 +522,13 @@ const commands = (/** @type {Map<RegExp, CommentAction>} */(new Map()))
await triggerGHActionWithComment(request, "run-twoslash-repros", { number: issueNumber || prNumber || undefined }, `run the code sample repros`);
}, undefined, false));


const botCall = "@typescript-bot";
for (const [key, value] of [...commands.entries()]) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is done early so we don't recalculate each regex multiple times; I could have done this up front in the regexes above or made an add method, but I didn't want to make the diff that bad.

@jakebailey jakebailey merged commit 5a177e0 into microsoft:master Sep 7, 2023
2 checks passed
@jakebailey jakebailey deleted the line-split branch September 7, 2023 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants