mirror of
https://github.com/actions/stale.git
synced 2026-02-11 08:38:17 +00:00
feat: enhance IssuesProcessor to return label creation date and events, add stale label event checks
This commit is contained in:
@@ -4,6 +4,7 @@ import {IComment} from '../../src/interfaces/comment';
|
||||
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';
|
||||
import {IPullRequest} from '../../src/interfaces/pull-request';
|
||||
import {IState} from '../../src/interfaces/state/state';
|
||||
import {IIssueEvent} from '../../src/interfaces/issue-event';
|
||||
|
||||
export class IssuesProcessorMock extends IssuesProcessor {
|
||||
constructor(
|
||||
@@ -17,7 +18,15 @@ export class IssuesProcessorMock extends IssuesProcessor {
|
||||
getLabelCreationDate?: (
|
||||
issue: Issue,
|
||||
label: string
|
||||
) => Promise<string | undefined>,
|
||||
) =>
|
||||
| Promise<string | undefined>
|
||||
| Promise<{creationDate?: string; events: IIssueEvent[]}>,
|
||||
hasOnlyStaleLabelingEventsSince?: (
|
||||
issue: Issue,
|
||||
sinceDate: string,
|
||||
staleLabel: string,
|
||||
events: IIssueEvent[]
|
||||
) => Promise<boolean>,
|
||||
getPullRequest?: (issue: Issue) => Promise<IPullRequest | undefined | void>
|
||||
) {
|
||||
super(options, state);
|
||||
@@ -31,7 +40,21 @@ export class IssuesProcessorMock extends IssuesProcessor {
|
||||
}
|
||||
|
||||
if (getLabelCreationDate) {
|
||||
this.getLabelCreationDate = getLabelCreationDate;
|
||||
this.getLabelCreationDate = async (
|
||||
issue: Issue,
|
||||
label: string
|
||||
): Promise<{creationDate?: string; events: IIssueEvent[]}> => {
|
||||
const result = await getLabelCreationDate(issue, label);
|
||||
if (typeof result === 'string' || typeof result === 'undefined') {
|
||||
return {creationDate: result, events: []};
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
if (hasOnlyStaleLabelingEventsSince) {
|
||||
this.hasOnlyStaleLabelingEventsSince = hasOnlyStaleLabelingEventsSince;
|
||||
}
|
||||
|
||||
if (getPullRequest) {
|
||||
|
||||
Reference in New Issue
Block a user