Skip to content

Commit

Permalink
Replaced id with number field
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmauro committed Sep 30, 2023
1 parent 04b1aae commit 52508ac
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

49 changes: 31 additions & 18 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,39 @@ async function run(): Promise<void> {
let issueUrl = '';
let existingIssue: Record<string, any>|null = null;
if (searchType != 'none') {
for await (const response of octokit.paginate.iterator(
octokit.rest.issues.listForRepo,
{
repo,
owner,
state: searchType as 'open' | 'closed' | 'all',
labels: searchLabels,
per_page: 100,
}
)) {
for (const issue of response.data) {
if ((!searchTitleRegex) || searchTitleRegex.test(title)) {
existingIssue = issue;
issueId = issue.id;
issueUrl = issue.url;
try {
for await (const response of octokit.paginate.iterator(
octokit.rest.issues.listForRepo,
{
repo,
owner,
state: searchType as 'open' | 'closed' | 'all',
labels: searchLabels,
per_page: 100
}
)) {
for (const issue of response.data) {
if ((!searchTitleRegex) || searchTitleRegex.test(title)) {
// Convert labels to just strings (we don't handle the other properties)
existingIssue = issue;
if (existingIssue.labels) {
existingIssue.labels = existingIssue.labels.map((x: any) => ((typeof x === 'object') ? x.name : x));
}

issueId = issue.number;
issueUrl = issue.url;
break;
}
}
if (issueId > 0) {
break;
}
}
if (issueId > 0) {
break;
}
catch (err: any) {
// Handle issue not found error
if (err.status !== 404 && err.message !== 'Not Found') {
throw err;
}
}
}
Expand Down Expand Up @@ -178,7 +191,7 @@ async function run(): Promise<void> {
milestone
})
});
issueId = data.id;
issueId = data.number;
issueUrl = data.url;
issueAction = 'created';
}
Expand Down

0 comments on commit 52508ac

Please sign in to comment.