Skip to content

Commit

Permalink
fix: no similarity edit
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Oct 26, 2024
1 parent 1f2a2a1 commit 6e26406
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/handlers/issue-deduplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ export async function issueChecker(context: Context): Promise<boolean> {
}
} else {
//Use the IssueBody (Without footnotes) to update the issue when no similar issues are found
await octokit.issues.update({
owner: payload.repository.owner.login,
repo: payload.repository.name,
issue_number: issue.number,
body: issueBody,
});
//Only if the issue has "possible duplicate" footnotes, update the issue
if (checkIfDuplicateFootNoteExists(issue.body || "")) {
await octokit.issues.update({
owner: payload.repository.owner.login,
repo: payload.repository.name,
issue_number: issue.number,
body: issueBody,
});
}
}
context.logger.info("No similar issues found");
return false;
Expand Down Expand Up @@ -291,3 +294,9 @@ export function removeFootnotes(content: string): string {
}
return contentWithoutFootnotes;
}

function checkIfDuplicateFootNoteExists(content: string): boolean {
const footnoteDefRegex = /\[\^(\d+)\^\]: ⚠ \d+% possible duplicate - [^\n]+(\n|$)/g;
const footnotes = content.match(footnoteDefRegex);
return !!footnotes;
}

0 comments on commit 6e26406

Please sign in to comment.