Merge pull request #6 from actions/case-insensitive-bugfix
bugfix for case insensitive issues
This commit is contained in:
commit
903ff7344d
23
src/main.ts
23
src/main.ts
|
@ -2,6 +2,9 @@ import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
import * as Octokit from '@octokit/rest';
|
import * as Octokit from '@octokit/rest';
|
||||||
|
|
||||||
|
type Issue = Octokit.IssuesListForRepoResponseItem;
|
||||||
|
type IssueLabel = Octokit.IssuesListForRepoResponseItemLabelsItem;
|
||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
repoToken: string;
|
repoToken: string;
|
||||||
staleIssueMessage: string;
|
staleIssueMessage: string;
|
||||||
|
@ -51,7 +54,7 @@ async function processIssues(
|
||||||
|
|
||||||
let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage;
|
let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage;
|
||||||
if (!staleMessage) {
|
if (!staleMessage) {
|
||||||
core.debug(`skipping ${isPr ? "pr" : "issue"} due to empty message`);
|
core.debug(`skipping ${isPr ? 'pr' : 'issue'} due to empty message`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,19 +85,13 @@ async function processIssues(
|
||||||
return await processIssues(client, args, operationsLeft, page + 1);
|
return await processIssues(client, args, operationsLeft, page + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLabeledStale(
|
function isLabeledStale(issue: Issue, label: string): boolean {
|
||||||
issue: Octokit.IssuesListForRepoResponseItem,
|
const labelComparer: (l: IssueLabel) => boolean = l =>
|
||||||
label: string
|
label.localeCompare(l.name, undefined, {sensitivity: 'accent'}) === 0;
|
||||||
): boolean {
|
|
||||||
const labelComparer = l =>
|
|
||||||
label.localeCompare(l.name, undefined, {sensitivity: 'accent'});
|
|
||||||
return issue.labels.filter(labelComparer).length > 0;
|
return issue.labels.filter(labelComparer).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function wasLastUpdatedBefore(
|
function wasLastUpdatedBefore(issue: Issue, num_days: number): boolean {
|
||||||
issue: Octokit.IssuesListForRepoResponseItem,
|
|
||||||
num_days: number
|
|
||||||
): boolean {
|
|
||||||
const daysInMillis = 1000 * 60 * 60 * num_days;
|
const daysInMillis = 1000 * 60 * 60 * num_days;
|
||||||
const millisSinceLastUpdated =
|
const millisSinceLastUpdated =
|
||||||
new Date().getTime() - new Date(issue.updated_at).getTime();
|
new Date().getTime() - new Date(issue.updated_at).getTime();
|
||||||
|
@ -103,7 +100,7 @@ function wasLastUpdatedBefore(
|
||||||
|
|
||||||
async function markStale(
|
async function markStale(
|
||||||
client: github.GitHub,
|
client: github.GitHub,
|
||||||
issue: Octokit.IssuesListForRepoResponseItem,
|
issue: Issue,
|
||||||
staleMessage: string,
|
staleMessage: string,
|
||||||
staleLabel: string
|
staleLabel: string
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
|
@ -128,7 +125,7 @@ async function markStale(
|
||||||
|
|
||||||
async function closeIssue(
|
async function closeIssue(
|
||||||
client: github.GitHub,
|
client: github.GitHub,
|
||||||
issue: Octokit.IssuesListForRepoResponseItem
|
issue: Issue
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
core.debug(`closing issue ${issue.title} for being stale`);
|
core.debug(`closing issue ${issue.title} for being stale`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue