Closed jsfour closed 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...
To achieve this, you can follow these steps:
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.
@imwalterbot APPROVE
@imwalterbot APPROVE
Queued for processing...
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!
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?