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 problem with approve #66

Open
jsfour opened this issue Mar 20, 2023 · 7 comments
Open

Fix problem with approve #66

jsfour opened this issue Mar 20, 2023 · 7 comments

Comments

@jsfour
Copy link
Member

jsfour commented Mar 20, 2023

No description provided.

@jsfour
Copy link
Member Author

jsfour commented Mar 20, 2023

What is a more expressive way of handling the "approve" process here https://github.com/octaviuslabs/walter/blob/main/index.ts#L196

@imwalterbot
Copy link
Contributor

What is a more expressive way of handling the "approve" process here https://github.com/octaviuslabs/walter/blob/main/index.ts#L196

Queued for processing...

@imwalterbot
Copy link
Contributor

To make the "approve" process more expressive, we can refactor the code to use more descriptive function and variable names, and also add comments to explain the logic. Here's a possible solution using pseudocode:

function isCommentApproving(commentBody: string, botName: string): boolean {
  const approvePattern = new RegExp(`@${botName}\\s*APPROVED`, "i");
  return approvePattern.test(commentBody);
}

function parseComment(comment: any): CommentAction {
  // Check if the comment is approving
  if (isCommentApproving(comment.body, BOT_NAME)) {
    return { type: "approve", body: comment.body };
  }

  // If the comment is not approving, consider it as a design comment
  return { type: "design", body: comment.body };
}

This refactoring makes it clearer that the function is checking if the comment is approving by using a dedicated function isCommentApproving. The function and variable names are also more descriptive, making the code easier to understand.

@jsfour
Copy link
Member Author

jsfour commented Mar 20, 2023

@jsfour
Copy link
Member Author

jsfour commented Mar 20, 2023

@imwalterbot
Copy link
Contributor

@imwalterbot APPROVED for https://github.com/octaviuslabs/walter/blob/main/index.ts#L196 changes

Queued for processing...

@imwalterbot
Copy link
Contributor

@imwalterbot APPROVED for https://github.com/octaviuslabs/walter/blob/main/index.ts#L196 changes

Processing this now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants