Skip to content

Commit

Permalink
Fetch issues for duplicate check properly
Browse files Browse the repository at this point in the history
  • Loading branch information
arkon committed Mar 25, 2023
1 parent bb7fa55 commit 5001d01
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
duplicate-check-enabled: true
duplicate-check-labels: |
["enhancement"]
["enhancement", "question"]
existing-check-enabled: true
existing-check-labels: |
["enhancement"]
["enhancement", "question"]
auto-close-rules: |
[
{
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions src/feature/dupe-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function checkForDuplicates() {
labelsToCheck = [core.getInput('duplicate-check-label')];
}

const hasRelevantLabel = issue.labels?.find((label) =>
const hasRelevantLabel = issue.labels?.some((label) =>
labelsToCheck.includes(label.name),
);
if (!hasRelevantLabel) {
Expand All @@ -51,13 +51,18 @@ export async function checkForDuplicates() {

const { repo } = github.context;

const allOpenIssues = await client.paginate(client.rest.issues.listForRepo, {
owner: repo.owner,
repo: repo.repo,
state: 'open',
labels: labelsToCheck.join(','),
per_page: 100,
});
const results = await Promise.all(
labelsToCheck.map((label) =>
client.paginate(client.rest.issues.listForRepo, {
owner: repo.owner,
repo: repo.repo,
state: 'open',
labels: label,
per_page: 100,
}),
),
);
const allOpenIssues = results.flat();

const duplicateIssues = allOpenIssues
.map((currIssue) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/feature/existing-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function checkForExisting() {
labelsToCheck = [core.getInput('existing-check-label')];
}

const hasRelevantLabel = issue.labels?.find((label) =>
const hasRelevantLabel = issue.labels?.some((label) =>
labelsToCheck.includes(label.name),
);
if (!hasRelevantLabel) {
Expand Down

0 comments on commit 5001d01

Please sign in to comment.