octaviuslabs / walter

AI-powered software development assistant built right into GitHub so it can act as your junior developer.
MIT License
8 stars 1 forks source link

Get Issue related to pull request #71

Closed jsfour closed 1 year ago

jsfour commented 1 year ago

We need to be able to pull the related issue from the pull request description and log it here: https://github.com/octaviuslabs/walter/blob/main/src/index.ts#L193

Can you come up with an approach?

imwalterbot commented 1 year ago

We need to be able to pull the related issue from the pull request description and log it here: https://github.com/octaviuslabs/walter/blob/main/src/index.ts#L193

Can you come up with an approach?

Queued for processing...

imwalterbot commented 1 year ago

To achieve this, you can follow these steps:

  1. Add a function to extract the related issue number from the pull request description.
  2. Update the webhooks.on("pull_request_review_comment.created" event to call this function and log the extracted issue number.

Here's the pseudocode for the solution:

function extractRelatedIssueNumber(prDescription: string): number | null {
  // Define a regex pattern to match the related issue number
  const issueRegex = /(?:Related|Fixes|Closes|Resolves)?\s*#(\d+)/i;

  // Search for the issue number in the pull request description
  const match = prDescription.match(issueRegex);

  // If a match is found, return the issue number
  if (match && match[1]) {
    return parseInt(match[1]);
  }

  // If no match is found, return null
  return null;
}

webhooks.on("pull_request_review_comment.created", async (event: any) => {
  const comment = event.payload.comment;
  const prDescription = event.payload.pull_request.body;
  Log.info("Pull request comment body:", comment.body);

  // Extract the related issue number from the pull request description
  const relatedIssueNumber = extractRelatedIssueNumber(prDescription);

  // Log the extracted issue number
  if (relatedIssueNumber) {
    Log.info("Related issue number:", relatedIssueNumber);
  } else {
    Log.info("No related issue number found in the pull request description.");
  }

  // Continue with the rest of the code...
});

This pseudocode will extract the related issue number from the pull request description and log it. Make sure to adapt this pseudocode to fit your existing code structure and conventions.

jsfour commented 1 year ago

@imwalterbot APPROVE

imwalterbot commented 1 year ago

@imwalterbot APPROVE

Queued for processing...

imwalterbot commented 1 year ago

I'm glad you approve of the solution provided. If you have any more questions or need further assistance, feel free to ask. Good luck with your project!