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