Compare commits

..

4 Commits

Author SHA1 Message Date
Ross Brodbeck
6e01d91097 Fix operation counting 2020-05-26 09:13:49 -04:00
Ross Brodbeck
55ac880ddb Add ( 2020-05-26 09:06:01 -04:00
Ross Brodbeck
bb7acbc692 Fix un-stale logic in processor 2020-05-26 08:43:40 -04:00
Ross Brodbeck
6d710eccec Update dits 2020-05-26 05:27:59 -04:00
3 changed files with 988 additions and 1126 deletions

View File

@@ -62,36 +62,11 @@ test('empty issue list results in 1 operation', async () => {
expect(operationsLeft).toEqual(99);
});
test('processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to 0', async () => {
test('processing an issue with no label will make it stale and close it, if it is old enough', async () => {
const TestIssueList: Issue[] = [
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z')
];
const opts = {...DefaultProcessorOptions};
opts.daysBeforeClose = 0;
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.staleIssues.length).toEqual(1);
expect(processor.closedIssues.length).toEqual(1);
});
test('processing an issue with no label will make it stale and not close it if days-before-close is set to > 0', async () => {
const TestIssueList: Issue[] = [
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z')
];
const opts = {...DefaultProcessorOptions};
opts.daysBeforeClose = 15;
const processor = new IssueProcessor(
DefaultProcessorOptions,
async p => (p == 1 ? TestIssueList : []),
@@ -103,7 +78,7 @@ test('processing an issue with no label will make it stale and not close it if d
await processor.processIssues(1);
expect(processor.staleIssues.length).toEqual(1);
expect(processor.closedIssues.length).toEqual(0);
expect(processor.closedIssues.length).toEqual(1);
});
test('processing an issue with no label will make it stale but not close it', async () => {

2076
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -203,7 +203,7 @@ export class IssueProcessor {
const issueHasUpdate: boolean = IssueProcessor.updatedSince(
issue.updated_at,
this.options.daysBeforeClose
this.options.daysBeforeClose + (this.options.daysBeforeStale ?? 0)
);
core.info(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
@@ -304,11 +304,6 @@ export class IssueProcessor {
this.operationsLeft -= 2;
// if the issue is being marked stale, the updated date should be changed to right now
// so that close calculations work correctly
const newUpdatedAtDate: Date = new Date();
issue.updated_at = newUpdatedAtDate.toString();
if (this.options.debugOnly) {
return;
}
@@ -415,7 +410,7 @@ export class IssueProcessor {
const millisSinceLastUpdated =
new Date().getTime() - new Date(timestamp).getTime();
return millisSinceLastUpdated <= daysInMillis;
return millisSinceLastUpdated < daysInMillis;
}
private static parseCommaSeparatedString(s: string): string[] {