Update how stale handles exempt items (#874)
This commit is contained in:
parent
10dc265f2c
commit
eed91cbd05
|
@ -246,8 +246,8 @@ Required Permission: `pull-requests: write`
|
||||||
|
|
||||||
#### exempt-issue-labels
|
#### exempt-issue-labels
|
||||||
|
|
||||||
The label(s) that can exempt to automatically mark as stale the issues.
|
Comma separated list of labels that can be assigned to issues to exclude them from being marked as stale
|
||||||
It can be a comma separated list of labels (e.g: `question,bug`).
|
(e.g: `question,bug`)
|
||||||
|
|
||||||
If unset (or an empty string), this option will not alter the stale workflow.
|
If unset (or an empty string), this option will not alter the stale workflow.
|
||||||
|
|
||||||
|
@ -255,8 +255,8 @@ Default value: unset
|
||||||
|
|
||||||
#### exempt-pr-labels
|
#### exempt-pr-labels
|
||||||
|
|
||||||
The label(s) that can exempt to automatically mark as stale the pull requests.
|
Comma separated list of labels that can be assigned to pull requests to exclude them from being marked as stale
|
||||||
It can be a comma separated list of labels (e.g: `need-help,WIP`).
|
(e.g: `need-help,WIP`)
|
||||||
|
|
||||||
If unset (or an empty string), this option will not alter the stale workflow.
|
If unset (or an empty string), this option will not alter the stale workflow.
|
||||||
|
|
||||||
|
|
|
@ -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
|
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 () => {
|
test('stale issues should not be closed if days is set to -1', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeClose = -1;
|
opts.daysBeforeClose = -1;
|
||||||
|
|
|
@ -523,20 +523,17 @@ class IssuesProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (issue.isStale) {
|
if (issue.isStale) {
|
||||||
issueLogger.info(`This $$type has a stale label`);
|
issueLogger.info(`This $$type includes a stale label`);
|
||||||
}
|
}
|
||||||
else {
|
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
|
const exemptLabels = words_to_list_1.wordsToList(issue.isPullRequest
|
||||||
? this.options.exemptPrLabels
|
? this.options.exemptPrLabels
|
||||||
: this.options.exemptIssueLabels);
|
: this.options.exemptIssueLabels);
|
||||||
if (exemptLabels.some((exemptLabel) => is_labeled_1.isLabeled(issue, exemptLabel))) {
|
const hasExemptLabel = exemptLabels.some((exemptLabel) => is_labeled_1.isLabeled(issue, exemptLabel));
|
||||||
if (issue.isStale) {
|
if (hasExemptLabel) {
|
||||||
issueLogger.info(`An exempt label was added after the stale label.`);
|
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`);
|
||||||
yield this._removeStaleLabel(issue, staleLabel);
|
|
||||||
}
|
|
||||||
issueLogger.info(`Skipping this $$type because it has an exempt label`);
|
|
||||||
IssuesProcessor._endIssueProcessing(issue);
|
IssuesProcessor._endIssueProcessing(issue);
|
||||||
return; // Don't process exempt issues
|
return; // Don't process exempt issues
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,9 +321,9 @@ export class IssuesProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issue.isStale) {
|
if (issue.isStale) {
|
||||||
issueLogger.info(`This $$type has a stale label`);
|
issueLogger.info(`This $$type includes a stale label`);
|
||||||
} else {
|
} else {
|
||||||
issueLogger.info(`This $$type hasn't a stale label`);
|
issueLogger.info(`This $$type does not include a stale label`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const exemptLabels: string[] = wordsToList(
|
const exemptLabels: string[] = wordsToList(
|
||||||
|
@ -332,17 +332,16 @@ export class IssuesProcessor {
|
||||||
: this.options.exemptIssueLabels
|
: this.options.exemptIssueLabels
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
const hasExemptLabel = exemptLabels.some((exemptLabel: Readonly<string>) =>
|
||||||
exemptLabels.some((exemptLabel: Readonly<string>): boolean =>
|
|
||||||
isLabeled(issue, exemptLabel)
|
isLabeled(issue, exemptLabel)
|
||||||
)
|
);
|
||||||
) {
|
|
||||||
if (issue.isStale) {
|
|
||||||
issueLogger.info(`An exempt label was added after the stale label.`);
|
|
||||||
await this._removeStaleLabel(issue, staleLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
IssuesProcessor._endIssueProcessing(issue);
|
||||||
return; // Don't process exempt issues
|
return; // Don't process exempt issues
|
||||||
}
|
}
|
||||||
|
@ -427,6 +426,7 @@ export class IssuesProcessor {
|
||||||
// Determine if this issue needs to be marked stale first
|
// Determine if this issue needs to be marked stale first
|
||||||
if (!issue.isStale) {
|
if (!issue.isStale) {
|
||||||
issueLogger.info(`This $$type is not stale`);
|
issueLogger.info(`This $$type is not stale`);
|
||||||
|
|
||||||
const shouldIgnoreUpdates: boolean = new IgnoreUpdates(
|
const shouldIgnoreUpdates: boolean = new IgnoreUpdates(
|
||||||
this.options,
|
this.options,
|
||||||
issue
|
issue
|
||||||
|
|
Loading…
Reference in New Issue