mirror of
https://github.com/actions/stale.git
synced 2025-12-11 12:37:27 +00:00
Update issue.updated_at if we have just marked an issue stale (#85)
This is to ensure we do not close issues before days-before-close has expired. Without this fix we can encounter a situation where an issue gets marked as stale and it gets closed immediately without waiting days-before-close number of days.
This commit is contained in:
@@ -304,6 +304,20 @@ 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;
|
||||
const newUpdatedAtDate: Date = new Date();
|
||||
newUpdatedAtDate.setTime(
|
||||
newUpdatedAtDate.getTime() - daysBeforeStaleInMillis
|
||||
);
|
||||
|
||||
issue.updated_at = newUpdatedAtDate.toString();
|
||||
|
||||
if (this.options.debugOnly) {
|
||||
return;
|
||||
}
|
||||
@@ -410,7 +424,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[] {
|
||||
|
||||
Reference in New Issue
Block a user