mirror of
https://github.com/actions/stale.git
synced 2025-12-11 04:32:53 +00:00
[Bugfix-795] Fix date comparison edge case (#816)
* Fix updatedAt and markedStaleOn date comparison * Delete accidental file * Refactor * Cleanup * cleanup
This commit is contained in:
21
dist/index.js
vendored
21
dist/index.js
vendored
@@ -742,7 +742,9 @@ class IssuesProcessor {
|
||||
if (issue.markedStaleThisRun) {
|
||||
issueLogger.info(`marked stale this run, so don't check for updates`);
|
||||
}
|
||||
const issueHasUpdateSinceStale = new Date(issue.updated_at) > new Date(markedStaleOn);
|
||||
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
||||
// isDateMoreRecentThan makes sure they are not the same date within a certain tolerance (15 seconds in this case)
|
||||
const issueHasUpdateSinceStale = is_date_more_recent_than_1.isDateMoreRecentThan(new Date(issue.updated_at), new Date(markedStaleOn), 15);
|
||||
issueLogger.info(`$$type has been updated since it was marked stale: ${logger_service_1.LoggerService.cyan(issueHasUpdateSinceStale)}`);
|
||||
// Should we un-stale this issue?
|
||||
if (shouldRemoveStaleWhenUpdated &&
|
||||
@@ -1965,12 +1967,25 @@ exports.getHumanizedDate = getHumanizedDate;
|
||||
|
||||
"use strict";
|
||||
|
||||
/// returns false if the dates are equal within the `equalityToleranceInSeconds` number of seconds
|
||||
/// otherwise returns true if `comparedDate` is after `date`
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isDateMoreRecentThan = void 0;
|
||||
function isDateMoreRecentThan(date, comparedDate) {
|
||||
exports.isDateEqualTo = exports.isDateMoreRecentThan = void 0;
|
||||
function isDateMoreRecentThan(date, comparedDate, equalityToleranceInSeconds = 0) {
|
||||
if (equalityToleranceInSeconds > 0) {
|
||||
const areDatesEqual = isDateEqualTo(date, comparedDate, equalityToleranceInSeconds);
|
||||
return !areDatesEqual && date > comparedDate;
|
||||
}
|
||||
return date > comparedDate;
|
||||
}
|
||||
exports.isDateMoreRecentThan = isDateMoreRecentThan;
|
||||
function isDateEqualTo(date, otherDate, toleranceInSeconds) {
|
||||
const timestamp = date.getTime();
|
||||
const otherTimestamp = otherDate.getTime();
|
||||
const deltaInSeconds = Math.abs(timestamp - otherTimestamp) / 1000;
|
||||
return deltaInSeconds <= toleranceInSeconds;
|
||||
}
|
||||
exports.isDateEqualTo = isDateEqualTo;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
Reference in New Issue
Block a user