Skip to content

Commit

Permalink
fix: fixing issue reference requirements on pull request when theres …
Browse files Browse the repository at this point in the history
…multiple issue references@
  • Loading branch information
alexanmtz committed Dec 2, 2024
1 parent cd0bb30 commit 97f9002
Show file tree
Hide file tree
Showing 2 changed files with 304 additions and 218 deletions.
11 changes: 10 additions & 1 deletion modules/tasks/taskSolutionFetchData.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ function extractIssueReferences(text) {
return matches ? matches.map(match => match.slice(1)) : []; // Remove the '#' prefix
}

function extractIssueNumberFromURL(url) {
const match = url.match(/\/issues\/(\d+)(\/)?$/);
return match ? match[1] : null;
}


module.exports = Promise.method(async function fetchTaskSolutionData (solutionParams) {
return requestPromise({
uri: `https://api.github.com/repos/${solutionParams.owner}/${solutionParams.repositoryName}/pulls/${solutionParams.pullRequestId}`,
Expand Down Expand Up @@ -59,7 +65,10 @@ module.exports = Promise.method(async function fetchTaskSolutionData (solutionPa
}
}
const issueReferences = extractIssueReferences(pullRequestData.body)
if(issueReferences.length && task.dataValues.url.includes(issueReferences)) {
const issueNumber = extractIssueNumberFromURL(task.dataValues.url)
const issueReferencesMatch = issueReferences.some(issueReference => issueNumber === issueReference)

if(issueReferences.length && issueReferencesMatch) {
hasIssueReference = true
}

Expand Down
Loading

0 comments on commit 97f9002

Please sign in to comment.