mirror of
https://github.com/actions/stale.git
synced 2025-12-11 20:47:10 +00:00
Remove labels on stale (#959)
This commit is contained in:
@@ -123,6 +123,10 @@ export class IssuesProcessor {
|
||||
);
|
||||
}
|
||||
|
||||
const labelsToRemoveWhenStale: string[] = wordsToList(
|
||||
this.options.labelsToRemoveWhenStale
|
||||
);
|
||||
|
||||
const labelsToAddWhenUnstale: string[] = wordsToList(
|
||||
this.options.labelsToAddWhenUnstale
|
||||
);
|
||||
@@ -141,7 +145,8 @@ export class IssuesProcessor {
|
||||
await this.processIssue(
|
||||
issue,
|
||||
labelsToAddWhenUnstale,
|
||||
labelsToRemoveWhenUnstale
|
||||
labelsToRemoveWhenUnstale,
|
||||
labelsToRemoveWhenStale
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -179,7 +184,8 @@ export class IssuesProcessor {
|
||||
async processIssue(
|
||||
issue: Issue,
|
||||
labelsToAddWhenUnstale: Readonly<string>[],
|
||||
labelsToRemoveWhenUnstale: Readonly<string>[]
|
||||
labelsToRemoveWhenUnstale: Readonly<string>[],
|
||||
labelsToRemoveWhenStale: Readonly<string>[]
|
||||
): Promise<void> {
|
||||
this.statistics?.incrementProcessedItemsCount(issue);
|
||||
|
||||
@@ -509,6 +515,7 @@ export class IssuesProcessor {
|
||||
staleMessage,
|
||||
labelsToAddWhenUnstale,
|
||||
labelsToRemoveWhenUnstale,
|
||||
labelsToRemoveWhenStale,
|
||||
closeMessage,
|
||||
closeLabel
|
||||
);
|
||||
@@ -623,6 +630,7 @@ export class IssuesProcessor {
|
||||
staleMessage: string,
|
||||
labelsToAddWhenUnstale: Readonly<string>[],
|
||||
labelsToRemoveWhenUnstale: Readonly<string>[],
|
||||
labelsToRemoveWhenStale: Readonly<string>[],
|
||||
closeMessage?: string,
|
||||
closeLabel?: string
|
||||
) {
|
||||
@@ -671,6 +679,11 @@ export class IssuesProcessor {
|
||||
|
||||
if (issue.markedStaleThisRun) {
|
||||
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)
|
||||
@@ -699,7 +712,11 @@ export class IssuesProcessor {
|
||||
await this._removeStaleLabel(issue, staleLabel);
|
||||
|
||||
// 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);
|
||||
|
||||
issueLogger.info(`Skipping the process since the $$type is now un-stale`);
|
||||
@@ -1074,9 +1091,10 @@ export class IssuesProcessor {
|
||||
return this.options.removeStaleWhenUpdated;
|
||||
}
|
||||
|
||||
private async _removeLabelsWhenUnstale(
|
||||
private async _removeLabelsOnStatusTransition(
|
||||
issue: Issue,
|
||||
removeLabels: Readonly<string>[]
|
||||
removeLabels: Readonly<string>[],
|
||||
staleStatus: Option
|
||||
): Promise<void> {
|
||||
if (!removeLabels.length) {
|
||||
return;
|
||||
@@ -1086,7 +1104,7 @@ export class IssuesProcessor {
|
||||
|
||||
issueLogger.info(
|
||||
`Removing all the labels specified via the ${this._logger.createOptionLink(
|
||||
Option.LabelsToRemoveWhenUnstale
|
||||
staleStatus
|
||||
)} option.`
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user