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 1/4] 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`); From c7694b0ceaa88f0baba578ef42344cef2af70b74 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 7 Aug 2019 10:19:42 -0400 Subject: [PATCH 2/4] Packag nits (#5) --- package-lock.json | 4 ++-- package.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7e4b1d5..07a96f7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "node12-template-action", - "version": "0.0.0", + "name": "stale-action", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a295850d..6b0b76ad 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "node12-template-action", - "version": "0.0.0", + "name": "stale-action", + "version": "1.0.0", "private": true, - "description": "Node 12 template action", + "description": "Marks old issues and PRs as stale", "main": "lib/main.js", "scripts": { "build": "tsc", From 4924c684b50da4d51f7fbaa9ee53eb51aaeb4c8c Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 7 Aug 2019 10:33:00 -0400 Subject: [PATCH 3/4] More nits --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6b0b76ad..278fb905 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,12 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/actions/start-vm-action.git" + "url": "git+https://github.com/actions/stale.git" }, "keywords": [ "actions", "node", - "setup" + "stale" ], "author": "GitHub", "license": "MIT", From 898b0bc63fb1fbc1101ae7bb76479ae28f900cd7 Mon Sep 17 00:00:00 2001 From: Shawn Napora <17864647+shawnnapora@users.noreply.github.com> Date: Wed, 7 Aug 2019 10:36:13 -0400 Subject: [PATCH 4/4] format, IssueLabels -> IssueLabel --- src/main.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main.ts b/src/main.ts index 62dc3e05..c6154e30 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import * as github from '@actions/github'; import * as Octokit from '@octokit/rest'; type Issue = Octokit.IssuesListForRepoResponseItem; -type IssueLabels = Octokit.IssuesListForRepoResponseItemLabelsItem; +type IssueLabel = Octokit.IssuesListForRepoResponseItemLabelsItem; type Args = { repoToken: string; @@ -54,7 +54,7 @@ async function processIssues( let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage; if (!staleMessage) { - core.debug(`skipping ${isPr ? "pr" : "issue"} due to empty message`); + core.debug(`skipping ${isPr ? 'pr' : 'issue'} due to empty message`); continue; } @@ -85,19 +85,13 @@ async function processIssues( return await processIssues(client, args, operationsLeft, page + 1); } -function isLabeledStale( - issue: Issue, - label: string -): boolean { - const labelComparer : (l: IssueLabels) => boolean = l => +function isLabeledStale(issue: Issue, label: string): boolean { + const labelComparer: (l: IssueLabel) => boolean = l => label.localeCompare(l.name, undefined, {sensitivity: 'accent'}) === 0; return issue.labels.filter(labelComparer).length > 0; } -function wasLastUpdatedBefore( - issue: Issue, - num_days: number -): boolean { +function wasLastUpdatedBefore(issue: Issue, num_days: number): boolean { const daysInMillis = 1000 * 60 * 60 * num_days; const millisSinceLastUpdated = new Date().getTime() - new Date(issue.updated_at).getTime();