Fix stale closing logic by removing close date addition (#93)

This commit is contained in:
Ross Brodbeck 2020-06-08 12:45:13 -04:00 committed by GitHub
parent db0a20585c
commit c72e3d7ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1095 additions and 996 deletions

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.daysBeforeStale ?? 0)
this.options.daysBeforeClose
);
core.info(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
@ -304,18 +304,9 @@ export class IssueProcessor {
this.operationsLeft -= 2;
// We are about to modify the issue by adding a comment and applying a label, so update the modification timestamp
// to `days-before-stale` days ago to simulate as if we marked this issue stale on the very first day it actually
// became stale. This has the effect of respecting `days-before-close` no matter what value it is set to. The user
// can request to close the issue immediately by using `days-before-close` === 0, or they can set it to any number
// of days to wait before actually closing the issue.
const daysBeforeStaleInMillis =
1000 * 60 * 60 * 24 * this.options.daysBeforeStale;
// 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();
newUpdatedAtDate.setTime(
newUpdatedAtDate.getTime() - daysBeforeStaleInMillis
);
issue.updated_at = newUpdatedAtDate.toString();
if (this.options.debugOnly) {