From 2521dbb2449bcb6a410e9479abd04c595d5bd1e5 Mon Sep 17 00:00:00 2001 From: damccorm Date: Wed, 4 Sep 2019 16:38:09 -0400 Subject: [PATCH 1/2] Add option to not close stale --- action.yml | 2 +- src/main.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index b2bb534d0..2c1a5d6c6 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ inputs: description: 'The number of days old an issue can be before marking it stale' default: 60 days-before-close: - description: 'The number of days to wait to close an issue or pull request after it being marked stale' + description: 'The number of days to wait to close an issue or pull request after it being marked stale. Set to -1 to never close stale issues.' default: 7 stale-issue-label: description: 'The label to apply when an issue is stale' diff --git a/src/main.ts b/src/main.ts index b24d62871..e725be747 100644 --- a/src/main.ts +++ b/src/main.ts @@ -66,11 +66,16 @@ async function processIssues( if (exemptLabel && isLabeled(issue, exemptLabel)) { continue; } else if (isLabeled(issue, staleLabel)) { - if (wasLastUpdatedBefore(issue, args.daysBeforeClose)) { - operationsLeft -= await closeIssue(client, issue); - } else { + if (args.daysBeforeClose < 0) { continue; } + else { + if (wasLastUpdatedBefore(issue, args.daysBeforeClose)) { + operationsLeft -= await closeIssue(client, issue); + } else { + continue; + } + } } else if (wasLastUpdatedBefore(issue, args.daysBeforeStale)) { operationsLeft -= await markStale( client, From b8e29997c6f8797793b261d889b98796ed14d5e5 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Thu, 5 Sep 2019 09:57:15 -0400 Subject: [PATCH 2/2] Clean up --- src/main.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index e725be747..2624cfb43 100644 --- a/src/main.ts +++ b/src/main.ts @@ -66,16 +66,11 @@ async function processIssues( if (exemptLabel && isLabeled(issue, exemptLabel)) { continue; } else if (isLabeled(issue, staleLabel)) { - if (args.daysBeforeClose < 0) { + if (args.daysBeforeClose >= 0 && wasLastUpdatedBefore(issue, args.daysBeforeClose)) { + operationsLeft -= await closeIssue(client, issue); + } else { continue; } - else { - if (wasLastUpdatedBefore(issue, args.daysBeforeClose)) { - operationsLeft -= await closeIssue(client, issue); - } else { - continue; - } - } } else if (wasLastUpdatedBefore(issue, args.daysBeforeStale)) { operationsLeft -= await markStale( client,