From 1acc1d62d983cd2af9605e8a66c1808869f1eb32 Mon Sep 17 00:00:00 2001 From: Shawn Napora <17864647+shawnnapora@users.noreply.github.com> Date: Wed, 7 Aug 2019 10:14:20 -0400 Subject: [PATCH] bugfix for case insensitive issues --- src/main.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3a5dfc4e..62dc3e05 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,9 @@ import * as core from '@actions/core'; import * as github from '@actions/github'; import * as Octokit from '@octokit/rest'; +type Issue = Octokit.IssuesListForRepoResponseItem; +type IssueLabels = Octokit.IssuesListForRepoResponseItemLabelsItem; + type Args = { repoToken: string; staleIssueMessage: string; @@ -83,16 +86,16 @@ async function processIssues( } function isLabeledStale( - issue: Octokit.IssuesListForRepoResponseItem, + issue: Issue, label: string ): boolean { - const labelComparer = l => - label.localeCompare(l.name, undefined, {sensitivity: 'accent'}); + const labelComparer : (l: IssueLabels) => boolean = l => + label.localeCompare(l.name, undefined, {sensitivity: 'accent'}) === 0; return issue.labels.filter(labelComparer).length > 0; } function wasLastUpdatedBefore( - issue: Octokit.IssuesListForRepoResponseItem, + issue: Issue, num_days: number ): boolean { const daysInMillis = 1000 * 60 * 60 * num_days; @@ -103,7 +106,7 @@ function wasLastUpdatedBefore( async function markStale( client: github.GitHub, - issue: Octokit.IssuesListForRepoResponseItem, + issue: Issue, staleMessage: string, staleLabel: string ): Promise { @@ -128,7 +131,7 @@ async function markStale( async function closeIssue( client: github.GitHub, - issue: Octokit.IssuesListForRepoResponseItem + issue: Issue ): Promise { core.debug(`closing issue ${issue.title} for being stale`);