diff --git a/README.md b/README.md index b35614e4..41de7f22 100644 --- a/README.md +++ b/README.md @@ -246,8 +246,8 @@ Required Permission: `pull-requests: write` #### exempt-issue-labels -The label(s) that can exempt to automatically mark as stale the issues. -It can be a comma separated list of labels (e.g: `question,bug`). +Comma separated list of labels that can be assigned to issues to exclude them from being marked as stale +(e.g: `question,bug`) If unset (or an empty string), this option will not alter the stale workflow. @@ -255,8 +255,8 @@ Default value: unset #### exempt-pr-labels -The label(s) that can exempt to automatically mark as stale the pull requests. -It can be a comma separated list of labels (e.g: `need-help,WIP`). +Comma separated list of labels that can be assigned to pull requests to exclude them from being marked as stale +(e.g: `need-help,WIP`) If unset (or an empty string), this option will not alter the stale workflow. diff --git a/__tests__/main.spec.ts b/__tests__/main.spec.ts index 21882547..6f752864 100644 --- a/__tests__/main.spec.ts +++ b/__tests__/main.spec.ts @@ -1094,44 +1094,6 @@ test('exempt pr labels will not be marked stale', async () => { expect(processor.staleIssues).toHaveLength(2); // PR should get processed even though it has an exempt **issue** label }); -test('exempt issue labels will not be marked stale and will remove the existing stale label', async () => { - expect.assertions(3); - const opts = {...DefaultProcessorOptions}; - opts.exemptIssueLabels = 'Exempt'; - const TestIssueList: Issue[] = [ - generateIssue( - opts, - 1, - 'My first issue', - '2020-01-01T17:00:00Z', - '2020-01-01T17:00:00Z', - false, - ['Exempt', 'Stale'] - ) - ]; - const processor = new IssuesProcessorMock( - opts, - async p => (p === 1 ? TestIssueList : []), - async () => [ - { - user: { - login: 'notme', - type: 'User' - }, - body: 'Body' - } - ], // return a fake comment to indicate there was an update - async () => new Date().toDateString() - ); - - // process our fake issue list - await processor.processIssues(1); - - expect(processor.staleIssues.length).toStrictEqual(0); - expect(processor.closedIssues.length).toStrictEqual(0); - expect(processor.removedLabelIssues.length).toStrictEqual(1); -}); - test('stale issues should not be closed if days is set to -1', async () => { const opts = {...DefaultProcessorOptions}; opts.daysBeforeClose = -1; diff --git a/dist/index.js b/dist/index.js index 0e78fccc..f039f498 100644 --- a/dist/index.js +++ b/dist/index.js @@ -523,20 +523,17 @@ class IssuesProcessor { } } if (issue.isStale) { - issueLogger.info(`This $$type has a stale label`); + issueLogger.info(`This $$type includes a stale label`); } else { - issueLogger.info(`This $$type hasn't a stale label`); + issueLogger.info(`This $$type does not include a stale label`); } const exemptLabels = words_to_list_1.wordsToList(issue.isPullRequest ? this.options.exemptPrLabels : this.options.exemptIssueLabels); - if (exemptLabels.some((exemptLabel) => is_labeled_1.isLabeled(issue, exemptLabel))) { - if (issue.isStale) { - issueLogger.info(`An exempt label was added after the stale label.`); - yield this._removeStaleLabel(issue, staleLabel); - } - issueLogger.info(`Skipping this $$type because it has an exempt label`); + const hasExemptLabel = exemptLabels.some((exemptLabel) => is_labeled_1.isLabeled(issue, exemptLabel)); + if (hasExemptLabel) { + issueLogger.info(`Skipping this $$type because it contains an exempt label, see ${issueLogger.createOptionLink(issue.isPullRequest ? option_1.Option.ExemptPrLabels : option_1.Option.ExemptIssueLabels)} for more details`); IssuesProcessor._endIssueProcessing(issue); return; // Don't process exempt issues } diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 70e3bf24..07aff68f 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -321,9 +321,9 @@ export class IssuesProcessor { } if (issue.isStale) { - issueLogger.info(`This $$type has a stale label`); + issueLogger.info(`This $$type includes a stale label`); } else { - issueLogger.info(`This $$type hasn't a stale label`); + issueLogger.info(`This $$type does not include a stale label`); } const exemptLabels: string[] = wordsToList( @@ -332,17 +332,16 @@ export class IssuesProcessor { : this.options.exemptIssueLabels ); - if ( - exemptLabels.some((exemptLabel: Readonly): boolean => - isLabeled(issue, exemptLabel) - ) - ) { - if (issue.isStale) { - issueLogger.info(`An exempt label was added after the stale label.`); - await this._removeStaleLabel(issue, staleLabel); - } + const hasExemptLabel = exemptLabels.some((exemptLabel: Readonly) => + isLabeled(issue, exemptLabel) + ); - issueLogger.info(`Skipping this $$type because it has an exempt label`); + if (hasExemptLabel) { + issueLogger.info( + `Skipping this $$type because it contains an exempt label, see ${issueLogger.createOptionLink( + issue.isPullRequest ? Option.ExemptPrLabels : Option.ExemptIssueLabels + )} for more details` + ); IssuesProcessor._endIssueProcessing(issue); return; // Don't process exempt issues } @@ -427,6 +426,7 @@ export class IssuesProcessor { // Determine if this issue needs to be marked stale first if (!issue.isStale) { issueLogger.info(`This $$type is not stale`); + const shouldIgnoreUpdates: boolean = new IgnoreUpdates( this.options, issue