Remove labels on stale (#959)
This commit is contained in:
parent
01aa53266c
commit
75d4d955ac
10
README.md
10
README.md
|
@ -63,6 +63,7 @@ Every argument is optional.
|
||||||
| [remove-issue-stale-when-updated](#remove-issue-stale-when-updated) | Remove stale label from issues on updates/comments | |
|
| [remove-issue-stale-when-updated](#remove-issue-stale-when-updated) | Remove stale label from issues on updates/comments | |
|
||||||
| [remove-pr-stale-when-updated](#remove-pr-stale-when-updated) | Remove stale label from PRs on updates/comments | |
|
| [remove-pr-stale-when-updated](#remove-pr-stale-when-updated) | Remove stale label from PRs on updates/comments | |
|
||||||
| [labels-to-add-when-unstale](#labels-to-add-when-unstale) | Add specified labels from issues/PRs when they become unstale | |
|
| [labels-to-add-when-unstale](#labels-to-add-when-unstale) | Add specified labels from issues/PRs when they become unstale | |
|
||||||
|
| [labels-to-remove-when-stale](#labels-to-remove-when-stale) | Remove specified labels from issues/PRs when they become stale | |
|
||||||
| [labels-to-remove-when-unstale](#labels-to-remove-when-unstale) | Remove specified labels from issues/PRs when they become unstale | |
|
| [labels-to-remove-when-unstale](#labels-to-remove-when-unstale) | Remove specified labels from issues/PRs when they become unstale | |
|
||||||
| [debug-only](#debug-only) | Dry-run | `false` |
|
| [debug-only](#debug-only) | Dry-run | `false` |
|
||||||
| [ascending](#ascending) | Order to get issues/PRs | `false` |
|
| [ascending](#ascending) | Order to get issues/PRs | `false` |
|
||||||
|
@ -358,6 +359,15 @@ A comma delimited list of labels to add when a stale issue or pull request recei
|
||||||
|
|
||||||
Default value: unset
|
Default value: unset
|
||||||
|
|
||||||
|
#### labels-to-remove-when-stale
|
||||||
|
|
||||||
|
A comma delimited list of labels to remove when an issue or pull request becomes stale and has the [stale-issue-label](#stale-issue-label) or [stale-pr-label](#stale-pr-label) added to it.
|
||||||
|
|
||||||
|
Warning: each label results in a unique API call which can drastically consume the limit of [operations-per-run](#operations-per-run).
|
||||||
|
|
||||||
|
Default value: unset
|
||||||
|
Required Permission: `pull-requests: write`
|
||||||
|
|
||||||
#### labels-to-remove-when-unstale
|
#### labels-to-remove-when-unstale
|
||||||
|
|
||||||
A comma delimited list of labels to remove when a stale issue or pull request receives activity and has the [stale-issue-label](#stale-issue-label) or [stale-pr-label](#stale-pr-label) removed from it.
|
A comma delimited list of labels to remove when a stale issue or pull request receives activity and has the [stale-issue-label](#stale-issue-label) or [stale-pr-label](#stale-pr-label) removed from it.
|
||||||
|
|
|
@ -47,6 +47,7 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||||
exemptAllIssueAssignees: undefined,
|
exemptAllIssueAssignees: undefined,
|
||||||
exemptAllPrAssignees: undefined,
|
exemptAllPrAssignees: undefined,
|
||||||
enableStatistics: true,
|
enableStatistics: true,
|
||||||
|
labelsToRemoveWhenStale: '',
|
||||||
labelsToRemoveWhenUnstale: '',
|
labelsToRemoveWhenUnstale: '',
|
||||||
labelsToAddWhenUnstale: '',
|
labelsToAddWhenUnstale: '',
|
||||||
ignoreUpdates: false,
|
ignoreUpdates: false,
|
||||||
|
|
|
@ -1220,6 +1220,48 @@ test('when the option "labelsToAddWhenUnstale" is set, the labels should be adde
|
||||||
expect(processor.addedLabelIssues).toHaveLength(1);
|
expect(processor.addedLabelIssues).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('when the option "labelsToRemoveWhenStale" is set, the labels should be removed when stale', async () => {
|
||||||
|
expect.assertions(3);
|
||||||
|
const opts = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
removeStaleWhenUpdated: true,
|
||||||
|
labelsToRemoveWhenStale: 'test'
|
||||||
|
};
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
opts,
|
||||||
|
1,
|
||||||
|
'An issue that should have labels removed to it when stale',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
['Stale', 'test']
|
||||||
|
)
|
||||||
|
];
|
||||||
|
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.closedIssues).toHaveLength(0);
|
||||||
|
expect(processor.staleIssues).toHaveLength(0);
|
||||||
|
// test label should have been removed
|
||||||
|
expect(processor.removedLabelIssues).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
test('stale label should not be removed if a comment was added by the bot (and the issue should be closed)', async () => {
|
test('stale label should not be removed if a comment was added by the bot (and the issue should be closed)', async () => {
|
||||||
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
||||||
github.context.actor = 'abot';
|
github.context.actor = 'abot';
|
||||||
|
|
|
@ -177,11 +177,15 @@ inputs:
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
labels-to-add-when-unstale:
|
labels-to-add-when-unstale:
|
||||||
description: 'A comma delimited list of labels to add when a stale issue or pull request receives activity and has the stale-issue-label or stale-pr-label removed from it.'
|
description: 'A comma delimited list of labels to add when an issue or pull request becomes unstale.'
|
||||||
|
default: ''
|
||||||
|
required: false
|
||||||
|
labels-to-remove-when-stale:
|
||||||
|
description: 'A comma delimited list of labels to remove when an issue or pull request becomes stale.'
|
||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
labels-to-remove-when-unstale:
|
labels-to-remove-when-unstale:
|
||||||
description: 'A comma delimited list of labels to remove when a stale issue or pull request receives activity and has the stale-issue-label or stale-pr-label removed from it.'
|
description: 'A comma delimited list of labels to remove when an issue or pull request becomes unstale.'
|
||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
ignore-updates:
|
ignore-updates:
|
||||||
|
|
|
@ -423,6 +423,7 @@ class IssuesProcessor {
|
||||||
else {
|
else {
|
||||||
this._logger.info(`${logger_service_1.LoggerService.yellow('Processing the batch of issues ')} ${logger_service_1.LoggerService.cyan(`#${page}`)} ${logger_service_1.LoggerService.yellow(' containing ')} ${logger_service_1.LoggerService.cyan(issues.length)} ${logger_service_1.LoggerService.yellow(` issue${issues.length > 1 ? 's' : ''}...`)}`);
|
this._logger.info(`${logger_service_1.LoggerService.yellow('Processing the batch of issues ')} ${logger_service_1.LoggerService.cyan(`#${page}`)} ${logger_service_1.LoggerService.yellow(' containing ')} ${logger_service_1.LoggerService.cyan(issues.length)} ${logger_service_1.LoggerService.yellow(` issue${issues.length > 1 ? 's' : ''}...`)}`);
|
||||||
}
|
}
|
||||||
|
const labelsToRemoveWhenStale = (0, words_to_list_1.wordsToList)(this.options.labelsToRemoveWhenStale);
|
||||||
const labelsToAddWhenUnstale = (0, words_to_list_1.wordsToList)(this.options.labelsToAddWhenUnstale);
|
const labelsToAddWhenUnstale = (0, words_to_list_1.wordsToList)(this.options.labelsToAddWhenUnstale);
|
||||||
const labelsToRemoveWhenUnstale = (0, words_to_list_1.wordsToList)(this.options.labelsToRemoveWhenUnstale);
|
const labelsToRemoveWhenUnstale = (0, words_to_list_1.wordsToList)(this.options.labelsToRemoveWhenUnstale);
|
||||||
for (const issue of issues.values()) {
|
for (const issue of issues.values()) {
|
||||||
|
@ -432,7 +433,7 @@ class IssuesProcessor {
|
||||||
}
|
}
|
||||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||||
yield issueLogger.grouping(`$$type #${issue.number}`, () => __awaiter(this, void 0, void 0, function* () {
|
yield issueLogger.grouping(`$$type #${issue.number}`, () => __awaiter(this, void 0, void 0, function* () {
|
||||||
yield this.processIssue(issue, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale);
|
yield this.processIssue(issue, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, labelsToRemoveWhenStale);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (!this.operations.hasRemainingOperations()) {
|
if (!this.operations.hasRemainingOperations()) {
|
||||||
|
@ -446,7 +447,7 @@ class IssuesProcessor {
|
||||||
return this.processIssues(page + 1);
|
return this.processIssues(page + 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
processIssue(issue, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale) {
|
processIssue(issue, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, labelsToRemoveWhenStale) {
|
||||||
var _a;
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementProcessedItemsCount(issue);
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementProcessedItemsCount(issue);
|
||||||
|
@ -626,7 +627,7 @@ class IssuesProcessor {
|
||||||
// Process the issue if it was marked stale
|
// Process the issue if it was marked stale
|
||||||
if (issue.isStale) {
|
if (issue.isStale) {
|
||||||
issueLogger.info(`This $$type is already stale`);
|
issueLogger.info(`This $$type is already stale`);
|
||||||
yield this._processStaleIssue(issue, staleLabel, staleMessage, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, closeMessage, closeLabel);
|
yield this._processStaleIssue(issue, staleLabel, staleMessage, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, labelsToRemoveWhenStale, closeMessage, closeLabel);
|
||||||
}
|
}
|
||||||
IssuesProcessor._endIssueProcessing(issue);
|
IssuesProcessor._endIssueProcessing(issue);
|
||||||
});
|
});
|
||||||
|
@ -721,7 +722,7 @@ class IssuesProcessor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// handle all of the stale issue logic when we find a stale issue
|
// handle all of the stale issue logic when we find a stale issue
|
||||||
_processStaleIssue(issue, staleLabel, staleMessage, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, closeMessage, closeLabel) {
|
_processStaleIssue(issue, staleLabel, staleMessage, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, labelsToRemoveWhenStale, closeMessage, closeLabel) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||||
const markedStaleOn = (yield this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
const markedStaleOn = (yield this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
||||||
|
@ -742,6 +743,7 @@ class IssuesProcessor {
|
||||||
}
|
}
|
||||||
if (issue.markedStaleThisRun) {
|
if (issue.markedStaleThisRun) {
|
||||||
issueLogger.info(`marked stale this run, so don't check for updates`);
|
issueLogger.info(`marked stale this run, so don't check for updates`);
|
||||||
|
yield this._removeLabelsOnStatusTransition(issue, labelsToRemoveWhenStale, option_1.Option.LabelsToRemoveWhenStale);
|
||||||
}
|
}
|
||||||
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
||||||
// isDateMoreRecentThan makes sure they are not the same date within a certain tolerance (15 seconds in this case)
|
// isDateMoreRecentThan makes sure they are not the same date within a certain tolerance (15 seconds in this case)
|
||||||
|
@ -754,7 +756,7 @@ class IssuesProcessor {
|
||||||
issueLogger.info(`Remove the stale label since the $$type has been updated and the workflow should remove the stale label when updated`);
|
issueLogger.info(`Remove the stale label since the $$type has been updated and the workflow should remove the stale label when updated`);
|
||||||
yield this._removeStaleLabel(issue, staleLabel);
|
yield this._removeStaleLabel(issue, staleLabel);
|
||||||
// Are there labels to remove or add when an issue is no longer stale?
|
// Are there labels to remove or add when an issue is no longer stale?
|
||||||
yield this._removeLabelsWhenUnstale(issue, labelsToRemoveWhenUnstale);
|
yield this._removeLabelsOnStatusTransition(issue, labelsToRemoveWhenUnstale, option_1.Option.LabelsToRemoveWhenUnstale);
|
||||||
yield this._addLabelsWhenUnstale(issue, labelsToAddWhenUnstale);
|
yield this._addLabelsWhenUnstale(issue, labelsToAddWhenUnstale);
|
||||||
issueLogger.info(`Skipping the process since the $$type is now un-stale`);
|
issueLogger.info(`Skipping the process since the $$type is now un-stale`);
|
||||||
return; // Nothing to do because it is no longer stale
|
return; // Nothing to do because it is no longer stale
|
||||||
|
@ -1031,13 +1033,13 @@ class IssuesProcessor {
|
||||||
}
|
}
|
||||||
return this.options.removeStaleWhenUpdated;
|
return this.options.removeStaleWhenUpdated;
|
||||||
}
|
}
|
||||||
_removeLabelsWhenUnstale(issue, removeLabels) {
|
_removeLabelsOnStatusTransition(issue, removeLabels, staleStatus) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!removeLabels.length) {
|
if (!removeLabels.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||||
issueLogger.info(`Removing all the labels specified via the ${this._logger.createOptionLink(option_1.Option.LabelsToRemoveWhenUnstale)} option.`);
|
issueLogger.info(`Removing all the labels specified via the ${this._logger.createOptionLink(staleStatus)} option.`);
|
||||||
for (const label of removeLabels.values()) {
|
for (const label of removeLabels.values()) {
|
||||||
yield this._removeLabel(issue, label);
|
yield this._removeLabel(issue, label);
|
||||||
}
|
}
|
||||||
|
@ -1911,6 +1913,7 @@ var Option;
|
||||||
Option["ExemptAllIssueAssignees"] = "exempt-all-issue-assignees";
|
Option["ExemptAllIssueAssignees"] = "exempt-all-issue-assignees";
|
||||||
Option["ExemptAllPrAssignees"] = "exempt-all-pr-assignees";
|
Option["ExemptAllPrAssignees"] = "exempt-all-pr-assignees";
|
||||||
Option["EnableStatistics"] = "enable-statistics";
|
Option["EnableStatistics"] = "enable-statistics";
|
||||||
|
Option["LabelsToRemoveWhenStale"] = "labels-to-remove-when-stale";
|
||||||
Option["LabelsToRemoveWhenUnstale"] = "labels-to-remove-when-unstale";
|
Option["LabelsToRemoveWhenUnstale"] = "labels-to-remove-when-unstale";
|
||||||
Option["LabelsToAddWhenUnstale"] = "labels-to-add-when-unstale";
|
Option["LabelsToAddWhenUnstale"] = "labels-to-add-when-unstale";
|
||||||
Option["IgnoreUpdates"] = "ignore-updates";
|
Option["IgnoreUpdates"] = "ignore-updates";
|
||||||
|
@ -2240,6 +2243,7 @@ function _getAndValidateArgs() {
|
||||||
exemptAllIssueAssignees: _toOptionalBoolean('exempt-all-issue-assignees'),
|
exemptAllIssueAssignees: _toOptionalBoolean('exempt-all-issue-assignees'),
|
||||||
exemptAllPrAssignees: _toOptionalBoolean('exempt-all-pr-assignees'),
|
exemptAllPrAssignees: _toOptionalBoolean('exempt-all-pr-assignees'),
|
||||||
enableStatistics: core.getInput('enable-statistics') === 'true',
|
enableStatistics: core.getInput('enable-statistics') === 'true',
|
||||||
|
labelsToRemoveWhenStale: core.getInput('labels-to-remove-when-stale'),
|
||||||
labelsToRemoveWhenUnstale: core.getInput('labels-to-remove-when-unstale'),
|
labelsToRemoveWhenUnstale: core.getInput('labels-to-remove-when-unstale'),
|
||||||
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale'),
|
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale'),
|
||||||
ignoreUpdates: core.getInput('ignore-updates') === 'true',
|
ignoreUpdates: core.getInput('ignore-updates') === 'true',
|
||||||
|
|
|
@ -1988,9 +1988,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/jest": {
|
"@types/jest": {
|
||||||
"version": "29.4.0",
|
"version": "29.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.4.4.tgz",
|
||||||
"integrity": "sha512-VaywcGQ9tPorCX/Jkkni7RWGFfI11whqzs8dvxF41P17Z+z872thvEvlIbznjPJ02kl1HMX3LmLOonsj2n7HeQ==",
|
"integrity": "sha512-qezb65VIH7X1wobSnd6Lvdve7PXSyQRa3dljTkhTtDhi603RvHQCshSlJcuyMLHJpeHgY3NKwvDJWxMOOHxGDQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"expect": "^29.0.0",
|
"expect": "^29.0.0",
|
||||||
|
|
|
@ -56,6 +56,7 @@ describe('Issue', (): void => {
|
||||||
exemptAllIssueAssignees: undefined,
|
exemptAllIssueAssignees: undefined,
|
||||||
exemptAllPrAssignees: undefined,
|
exemptAllPrAssignees: undefined,
|
||||||
enableStatistics: false,
|
enableStatistics: false,
|
||||||
|
labelsToRemoveWhenStale: '',
|
||||||
labelsToRemoveWhenUnstale: '',
|
labelsToRemoveWhenUnstale: '',
|
||||||
labelsToAddWhenUnstale: '',
|
labelsToAddWhenUnstale: '',
|
||||||
ignoreUpdates: false,
|
ignoreUpdates: false,
|
||||||
|
|
|
@ -123,6 +123,10 @@ export class IssuesProcessor {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const labelsToRemoveWhenStale: string[] = wordsToList(
|
||||||
|
this.options.labelsToRemoveWhenStale
|
||||||
|
);
|
||||||
|
|
||||||
const labelsToAddWhenUnstale: string[] = wordsToList(
|
const labelsToAddWhenUnstale: string[] = wordsToList(
|
||||||
this.options.labelsToAddWhenUnstale
|
this.options.labelsToAddWhenUnstale
|
||||||
);
|
);
|
||||||
|
@ -141,7 +145,8 @@ export class IssuesProcessor {
|
||||||
await this.processIssue(
|
await this.processIssue(
|
||||||
issue,
|
issue,
|
||||||
labelsToAddWhenUnstale,
|
labelsToAddWhenUnstale,
|
||||||
labelsToRemoveWhenUnstale
|
labelsToRemoveWhenUnstale,
|
||||||
|
labelsToRemoveWhenStale
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -179,7 +184,8 @@ export class IssuesProcessor {
|
||||||
async processIssue(
|
async processIssue(
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
labelsToAddWhenUnstale: Readonly<string>[],
|
labelsToAddWhenUnstale: Readonly<string>[],
|
||||||
labelsToRemoveWhenUnstale: Readonly<string>[]
|
labelsToRemoveWhenUnstale: Readonly<string>[],
|
||||||
|
labelsToRemoveWhenStale: Readonly<string>[]
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
this.statistics?.incrementProcessedItemsCount(issue);
|
this.statistics?.incrementProcessedItemsCount(issue);
|
||||||
|
|
||||||
|
@ -509,6 +515,7 @@ export class IssuesProcessor {
|
||||||
staleMessage,
|
staleMessage,
|
||||||
labelsToAddWhenUnstale,
|
labelsToAddWhenUnstale,
|
||||||
labelsToRemoveWhenUnstale,
|
labelsToRemoveWhenUnstale,
|
||||||
|
labelsToRemoveWhenStale,
|
||||||
closeMessage,
|
closeMessage,
|
||||||
closeLabel
|
closeLabel
|
||||||
);
|
);
|
||||||
|
@ -623,6 +630,7 @@ export class IssuesProcessor {
|
||||||
staleMessage: string,
|
staleMessage: string,
|
||||||
labelsToAddWhenUnstale: Readonly<string>[],
|
labelsToAddWhenUnstale: Readonly<string>[],
|
||||||
labelsToRemoveWhenUnstale: Readonly<string>[],
|
labelsToRemoveWhenUnstale: Readonly<string>[],
|
||||||
|
labelsToRemoveWhenStale: Readonly<string>[],
|
||||||
closeMessage?: string,
|
closeMessage?: string,
|
||||||
closeLabel?: string
|
closeLabel?: string
|
||||||
) {
|
) {
|
||||||
|
@ -671,6 +679,11 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (issue.markedStaleThisRun) {
|
if (issue.markedStaleThisRun) {
|
||||||
issueLogger.info(`marked stale this run, so don't check for updates`);
|
issueLogger.info(`marked stale this run, so don't check for updates`);
|
||||||
|
await this._removeLabelsOnStatusTransition(
|
||||||
|
issue,
|
||||||
|
labelsToRemoveWhenStale,
|
||||||
|
Option.LabelsToRemoveWhenStale
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
||||||
|
@ -699,7 +712,11 @@ export class IssuesProcessor {
|
||||||
await this._removeStaleLabel(issue, staleLabel);
|
await this._removeStaleLabel(issue, staleLabel);
|
||||||
|
|
||||||
// Are there labels to remove or add when an issue is no longer stale?
|
// Are there labels to remove or add when an issue is no longer stale?
|
||||||
await this._removeLabelsWhenUnstale(issue, labelsToRemoveWhenUnstale);
|
await this._removeLabelsOnStatusTransition(
|
||||||
|
issue,
|
||||||
|
labelsToRemoveWhenUnstale,
|
||||||
|
Option.LabelsToRemoveWhenUnstale
|
||||||
|
);
|
||||||
await this._addLabelsWhenUnstale(issue, labelsToAddWhenUnstale);
|
await this._addLabelsWhenUnstale(issue, labelsToAddWhenUnstale);
|
||||||
|
|
||||||
issueLogger.info(`Skipping the process since the $$type is now un-stale`);
|
issueLogger.info(`Skipping the process since the $$type is now un-stale`);
|
||||||
|
@ -1074,9 +1091,10 @@ export class IssuesProcessor {
|
||||||
return this.options.removeStaleWhenUpdated;
|
return this.options.removeStaleWhenUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _removeLabelsWhenUnstale(
|
private async _removeLabelsOnStatusTransition(
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
removeLabels: Readonly<string>[]
|
removeLabels: Readonly<string>[],
|
||||||
|
staleStatus: Option
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!removeLabels.length) {
|
if (!removeLabels.length) {
|
||||||
return;
|
return;
|
||||||
|
@ -1086,7 +1104,7 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`Removing all the labels specified via the ${this._logger.createOptionLink(
|
`Removing all the labels specified via the ${this._logger.createOptionLink(
|
||||||
Option.LabelsToRemoveWhenUnstale
|
staleStatus
|
||||||
)} option.`
|
)} option.`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ export enum Option {
|
||||||
ExemptAllIssueAssignees = 'exempt-all-issue-assignees',
|
ExemptAllIssueAssignees = 'exempt-all-issue-assignees',
|
||||||
ExemptAllPrAssignees = 'exempt-all-pr-assignees',
|
ExemptAllPrAssignees = 'exempt-all-pr-assignees',
|
||||||
EnableStatistics = 'enable-statistics',
|
EnableStatistics = 'enable-statistics',
|
||||||
|
LabelsToRemoveWhenStale = 'labels-to-remove-when-stale',
|
||||||
LabelsToRemoveWhenUnstale = 'labels-to-remove-when-unstale',
|
LabelsToRemoveWhenUnstale = 'labels-to-remove-when-unstale',
|
||||||
LabelsToAddWhenUnstale = 'labels-to-add-when-unstale',
|
LabelsToAddWhenUnstale = 'labels-to-add-when-unstale',
|
||||||
IgnoreUpdates = 'ignore-updates',
|
IgnoreUpdates = 'ignore-updates',
|
||||||
|
|
|
@ -45,6 +45,7 @@ export interface IIssuesProcessorOptions {
|
||||||
exemptAllIssueAssignees: boolean | undefined;
|
exemptAllIssueAssignees: boolean | undefined;
|
||||||
exemptAllPrAssignees: boolean | undefined;
|
exemptAllPrAssignees: boolean | undefined;
|
||||||
enableStatistics: boolean;
|
enableStatistics: boolean;
|
||||||
|
labelsToRemoveWhenStale: string;
|
||||||
labelsToRemoveWhenUnstale: string;
|
labelsToRemoveWhenUnstale: string;
|
||||||
labelsToAddWhenUnstale: string;
|
labelsToAddWhenUnstale: string;
|
||||||
ignoreUpdates: boolean;
|
ignoreUpdates: boolean;
|
||||||
|
|
|
@ -82,6 +82,7 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||||
exemptAllIssueAssignees: _toOptionalBoolean('exempt-all-issue-assignees'),
|
exemptAllIssueAssignees: _toOptionalBoolean('exempt-all-issue-assignees'),
|
||||||
exemptAllPrAssignees: _toOptionalBoolean('exempt-all-pr-assignees'),
|
exemptAllPrAssignees: _toOptionalBoolean('exempt-all-pr-assignees'),
|
||||||
enableStatistics: core.getInput('enable-statistics') === 'true',
|
enableStatistics: core.getInput('enable-statistics') === 'true',
|
||||||
|
labelsToRemoveWhenStale: core.getInput('labels-to-remove-when-stale'),
|
||||||
labelsToRemoveWhenUnstale: core.getInput('labels-to-remove-when-unstale'),
|
labelsToRemoveWhenUnstale: core.getInput('labels-to-remove-when-unstale'),
|
||||||
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale'),
|
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale'),
|
||||||
ignoreUpdates: core.getInput('ignore-updates') === 'true',
|
ignoreUpdates: core.getInput('ignore-updates') === 'true',
|
||||||
|
|
Loading…
Reference in New Issue