parent
71d46bfe23
commit
5ce6b77f2c
|
@ -504,3 +504,64 @@ test('stale label should be removed if a comment was added to a stale issue', as
|
||||||
expect(processor.staleIssues.length).toEqual(0);
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
expect(processor.removedLabelIssues.length).toEqual(1);
|
expect(processor.removedLabelIssues.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('stale issues should not be closed until after the closed number of days', async () => {
|
||||||
|
let lastUpdate = new Date();
|
||||||
|
lastUpdate.setDate(lastUpdate.getDate() - 5);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'An issue that should be marked stale but not closed',
|
||||||
|
lastUpdate.toString(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = DefaultProcessorOptions;
|
||||||
|
opts.daysBeforeStale = 5; // stale after 5 days
|
||||||
|
opts.daysBeforeClose = 1; // closes after 6 days
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stale issues should be closed if the closed nubmer of days (additive) is also passed', async () => {
|
||||||
|
let lastUpdate = new Date();
|
||||||
|
lastUpdate.setDate(lastUpdate.getDate() - 7);
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'An issue that should be stale and closed',
|
||||||
|
lastUpdate.toString(),
|
||||||
|
false,
|
||||||
|
['Stale']
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = DefaultProcessorOptions;
|
||||||
|
opts.daysBeforeStale = 5; // stale after 5 days
|
||||||
|
opts.daysBeforeClose = 1; // closes after 6 days
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.closedIssues.length).toEqual(1);
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -67,7 +67,10 @@ export class IssueProcessor {
|
||||||
issueNumber: number,
|
issueNumber: number,
|
||||||
sinceDate: string
|
sinceDate: string
|
||||||
) => Promise<Comment[]>,
|
) => Promise<Comment[]>,
|
||||||
getLabelCreationDate?: (issue: Issue, label: string) => Promise<string | undefined>
|
getLabelCreationDate?: (
|
||||||
|
issue: Issue,
|
||||||
|
label: string
|
||||||
|
) => Promise<string | undefined>
|
||||||
) {
|
) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.operationsLeft = options.operationsPerRun;
|
this.operationsLeft = options.operationsPerRun;
|
||||||
|
@ -200,17 +203,20 @@ export class IssueProcessor {
|
||||||
);
|
);
|
||||||
const issueHasUpdate: boolean = IssueProcessor.updatedSince(
|
const issueHasUpdate: boolean = IssueProcessor.updatedSince(
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
this.options.daysBeforeClose
|
this.options.daysBeforeClose + (this.options.daysBeforeStale ?? 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (markedStaleOn) {
|
if (markedStaleOn) {
|
||||||
core.debug(`Issue #${issue.number} marked stale on: ${markedStaleOn}`);
|
core.debug(`Issue #${issue.number} marked stale on: ${markedStaleOn}`);
|
||||||
}
|
} else {
|
||||||
else {
|
core.debug(
|
||||||
core.debug(`Issue #${issue.number} is not marked stale, but last update of ${issue.updated_at} is older than ${this.options.daysBeforeStale} days`);
|
`Issue #${issue.number} is not marked stale, but last update of ${issue.updated_at} is older than ${this.options.daysBeforeStale} days`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
core.debug(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
|
core.debug(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
|
||||||
core.debug(`Issue #${issue.number} has been commented on: ${issueHasComments}`);
|
core.debug(
|
||||||
|
`Issue #${issue.number} has been commented on: ${issueHasComments}`
|
||||||
|
);
|
||||||
|
|
||||||
if (!issueHasComments && !issueHasUpdate) {
|
if (!issueHasComments && !issueHasUpdate) {
|
||||||
core.debug(
|
core.debug(
|
||||||
|
|
Loading…
Reference in New Issue