diff --git a/dist/index.js b/dist/index.js index 18754b23..f08e084c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -720,12 +720,14 @@ class IssuesProcessor { const issueLogger = new issue_logger_1.IssueLogger(issue); const markedStaleOn = (yield this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at; issueLogger.info(`$$type marked stale on: ${logger_service_1.LoggerService.cyan(markedStaleOn)}`); - const issueHasCommentsSinceStale = yield this._hasCommentsSince(issue, markedStaleOn, staleMessage); - issueLogger.info(`$$type has been commented on: ${logger_service_1.LoggerService.cyan(issueHasCommentsSinceStale)}`); + const issueHasComments = yield this._hasCommentsSince(issue, markedStaleOn, staleMessage); + issueLogger.info(`$$type has been commented on: ${logger_service_1.LoggerService.cyan(issueHasComments)}`); const daysBeforeClose = issue.isPullRequest ? this._getDaysBeforePrClose() : this._getDaysBeforeIssueClose(); issueLogger.info(`Days before $$type close: ${logger_service_1.LoggerService.cyan(daysBeforeClose)}`); + const issueHasUpdate = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose); + issueLogger.info(`$$type has been updated: ${logger_service_1.LoggerService.cyan(issueHasUpdate)}`); const shouldRemoveStaleWhenUpdated = this._shouldRemoveStaleWhenUpdated(issue); issueLogger.info(`The option ${issueLogger.createOptionLink(this._getRemoveStaleWhenUpdatedUsedOptionName(issue))} is: ${logger_service_1.LoggerService.cyan(shouldRemoveStaleWhenUpdated)}`); if (shouldRemoveStaleWhenUpdated) { @@ -737,11 +739,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); - 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 && - (issueHasUpdateSinceStale || issueHasCommentsSinceStale) && + (issueHasUpdate || issueHasComments) && !issue.markedStaleThisRun) { issueLogger.info(`Remove the stale label since the $$type has been updated and the workflow should remove the stale label when updated`); yield this._removeStaleLabel(issue, staleLabel); @@ -755,9 +755,7 @@ class IssuesProcessor { if (daysBeforeClose < 0) { return; // Nothing to do because we aren't closing stale issues } - const issueHasUpdateInCloseWindow = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose); - issueLogger.info(`$$type has been updated in the last ${daysBeforeClose} days: ${logger_service_1.LoggerService.cyan(issueHasUpdateInCloseWindow)}`); - if (!issueHasCommentsSinceStale && !issueHasUpdateInCloseWindow) { + if (!issueHasComments && !issueHasUpdate) { issueLogger.info(`Closing $$type because it was last updated on: ${logger_service_1.LoggerService.cyan(issue.updated_at)}`); yield this._closeIssue(issue, closeMessage, closeLabel); if (this.options.deleteBranch && issue.pull_request) { @@ -767,7 +765,7 @@ class IssuesProcessor { } } else { - issueLogger.info(`Stale $$type is not old enough to close yet (hasComments? ${issueHasCommentsSinceStale}, hasUpdate? ${issueHasUpdateInCloseWindow})`); + issueLogger.info(`Stale $$type is not old enough to close yet (hasComments? ${issueHasComments}, hasUpdate? ${issueHasUpdate})`); } }); } diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index d0397ebc..d603a5f2 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -625,15 +625,13 @@ export class IssuesProcessor { `$$type marked stale on: ${LoggerService.cyan(markedStaleOn)}` ); - const issueHasCommentsSinceStale: boolean = await this._hasCommentsSince( + const issueHasComments: boolean = await this._hasCommentsSince( issue, markedStaleOn, staleMessage ); issueLogger.info( - `$$type has been commented on: ${LoggerService.cyan( - issueHasCommentsSinceStale - )}` + `$$type has been commented on: ${LoggerService.cyan(issueHasComments)}` ); const daysBeforeClose: number = issue.isPullRequest @@ -644,6 +642,14 @@ export class IssuesProcessor { `Days before $$type close: ${LoggerService.cyan(daysBeforeClose)}` ); + const issueHasUpdate: boolean = IssuesProcessor._updatedSince( + issue.updated_at, + daysBeforeClose + ); + issueLogger.info( + `$$type has been updated: ${LoggerService.cyan(issueHasUpdate)}` + ); + const shouldRemoveStaleWhenUpdated: boolean = this._shouldRemoveStaleWhenUpdated(issue); @@ -665,19 +671,10 @@ export class IssuesProcessor { issueLogger.info(`marked stale this run, so don't check for updates`); } - const issueHasUpdateSinceStale = - new Date(issue.updated_at) > new Date(markedStaleOn); - - issueLogger.info( - `$$type has been updated since it was marked stale: ${LoggerService.cyan( - issueHasUpdateSinceStale - )}` - ); - // Should we un-stale this issue? if ( shouldRemoveStaleWhenUpdated && - (issueHasUpdateSinceStale || issueHasCommentsSinceStale) && + (issueHasUpdate || issueHasComments) && !issue.markedStaleThisRun ) { issueLogger.info( @@ -699,17 +696,7 @@ export class IssuesProcessor { return; // Nothing to do because we aren't closing stale issues } - const issueHasUpdateInCloseWindow: boolean = IssuesProcessor._updatedSince( - issue.updated_at, - daysBeforeClose - ); - issueLogger.info( - `$$type has been updated in the last ${daysBeforeClose} days: ${LoggerService.cyan( - issueHasUpdateInCloseWindow - )}` - ); - - if (!issueHasCommentsSinceStale && !issueHasUpdateInCloseWindow) { + if (!issueHasComments && !issueHasUpdate) { issueLogger.info( `Closing $$type because it was last updated on: ${LoggerService.cyan( issue.updated_at @@ -728,7 +715,7 @@ export class IssuesProcessor { } } else { issueLogger.info( - `Stale $$type is not old enough to close yet (hasComments? ${issueHasCommentsSinceStale}, hasUpdate? ${issueHasUpdateInCloseWindow})` + `Stale $$type is not old enough to close yet (hasComments? ${issueHasComments}, hasUpdate? ${issueHasUpdate})` ); } }