mirror of
https://github.com/actions/stale.git
synced 2025-12-23 08:58:17 +00:00
feat(options): add new option ignore-updates to stale even with activity (#540)
* chore(assignees): add logs * docs(readme): use the override syntax to simplify the reading * docs(readme): add missing default options * docs(readme): add 3 new options to ignore activity before stale * chore(action): add 3 new options * fix(removeStaleWhenUpdated): use the value of the action config as expected Fixes #451 * chore(main): add 3 new options * feat(ignore): add new class to ignore all activities before stale * feat(option): add new options to ignore all activities before stale * chore(index): update index file * docs(readme): fix typo * docs(readme): add missing empty row * chore(rebase): fix logger issues due to rebase * chore: aplly changes due to rebase * refactor(naming): change the name of the options as suggested * chore(logs): reverse the logs as well * docs(readme): format the table of options * refactor(naming): rename the the options * style(rename): rename more updates wording to activities * build(ci): run the test step as expected for a CI instead of using a real linter with auto fix and the tests verbose as fuck * chore: handle breaking changes due to new changes * refactor(naming): rename and reverse the options * style(tests): use plural for some describe * docs(days-before-stale): list the new option * chore(index): update index file * chore: keep static methods on top * chore(logs): remove useless log
This commit is contained in:
committed by
GitHub
parent
002bc97450
commit
1cdda06bb3
120
dist/index.js
vendored
120
dist/index.js
vendored
@@ -141,6 +141,67 @@ class Assignees {
|
||||
exports.Assignees = Assignees;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2935:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.IgnoreUpdates = void 0;
|
||||
const option_1 = __nccwpck_require__(5931);
|
||||
const issue_logger_1 = __nccwpck_require__(2984);
|
||||
class IgnoreUpdates {
|
||||
constructor(options, issue) {
|
||||
this._options = options;
|
||||
this._issue = issue;
|
||||
this._issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
}
|
||||
shouldIgnoreUpdates() {
|
||||
return this._shouldIgnoreUpdates();
|
||||
}
|
||||
_shouldIgnoreUpdates() {
|
||||
return this._issue.isPullRequest
|
||||
? this._shouldIgnorePullRequestUpdates()
|
||||
: this._shouldIgnoreIssueUpdates();
|
||||
}
|
||||
_shouldIgnorePullRequestUpdates() {
|
||||
if (this._options.ignorePrUpdates === true) {
|
||||
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.IgnorePrUpdates)} is enabled. The stale counter will ignore any updates or comments on this $$type and will use the creation date as a reference ignoring any kind of update`);
|
||||
return true;
|
||||
}
|
||||
else if (this._options.ignorePrUpdates === false) {
|
||||
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.IgnorePrUpdates)} is disabled. The stale counter will take into account updates and comments on this $$type to avoid to stale when there is some update`);
|
||||
return false;
|
||||
}
|
||||
this._logIgnoreUpdates();
|
||||
return this._options.ignoreUpdates;
|
||||
}
|
||||
_shouldIgnoreIssueUpdates() {
|
||||
if (this._options.ignoreIssueUpdates === true) {
|
||||
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.IgnoreIssueUpdates)} is enabled. The stale counter will ignore any updates or comments on this $$type and will use the creation date as a reference ignoring any kind of update`);
|
||||
return true;
|
||||
}
|
||||
else if (this._options.ignoreIssueUpdates === false) {
|
||||
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.IgnoreIssueUpdates)} is disabled. The stale counter will take into account updates and comments on this $$type to avoid to stale when there is some update`);
|
||||
return false;
|
||||
}
|
||||
this._logIgnoreUpdates();
|
||||
return this._options.ignoreUpdates;
|
||||
}
|
||||
_logIgnoreUpdates() {
|
||||
if (this._options.ignoreUpdates) {
|
||||
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.IgnoreUpdates)} is enabled. The stale counter will ignore any updates or comments on this $$type and will use the creation date as a reference ignoring any kind of update`);
|
||||
}
|
||||
else {
|
||||
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.IgnoreUpdates)} is disabled. The stale counter will take into account updates and comments on this $$type to avoid to stale when there is some update`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.IgnoreUpdates = IgnoreUpdates;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4783:
|
||||
@@ -236,6 +297,7 @@ const clean_label_1 = __nccwpck_require__(7752);
|
||||
const should_mark_when_stale_1 = __nccwpck_require__(2461);
|
||||
const words_to_list_1 = __nccwpck_require__(1883);
|
||||
const assignees_1 = __nccwpck_require__(7236);
|
||||
const ignore_updates_1 = __nccwpck_require__(2935);
|
||||
const issue_1 = __nccwpck_require__(4783);
|
||||
const issue_logger_1 = __nccwpck_require__(2984);
|
||||
const logger_1 = __nccwpck_require__(6212);
|
||||
@@ -248,12 +310,12 @@ const logger_service_1 = __nccwpck_require__(1973);
|
||||
*/
|
||||
class IssuesProcessor {
|
||||
constructor(options) {
|
||||
this._logger = new logger_1.Logger();
|
||||
this.staleIssues = [];
|
||||
this.closedIssues = [];
|
||||
this.deletedBranchIssues = [];
|
||||
this.removedLabelIssues = [];
|
||||
this.addedLabelIssues = [];
|
||||
this._logger = new logger_1.Logger();
|
||||
this.options = options;
|
||||
this.client = github_1.getOctokit(this.options.repoToken);
|
||||
this.operations = new stale_operations_1.StaleOperations(this.options);
|
||||
@@ -278,11 +340,6 @@ class IssuesProcessor {
|
||||
issueLogger.info(logger_service_1.LoggerService.cyan(consumedOperationsCount), `operation${consumedOperationsCount > 1 ? 's' : ''} consumed for this $$type`);
|
||||
}
|
||||
}
|
||||
static _getStaleMessageUsedOptionName(issue) {
|
||||
return issue.isPullRequest
|
||||
? option_1.Option.StalePrMessage
|
||||
: option_1.Option.StaleIssueMessage;
|
||||
}
|
||||
static _getCloseLabelUsedOptionName(issue) {
|
||||
return issue.isPullRequest ? option_1.Option.ClosePrLabel : option_1.Option.CloseIssueLabel;
|
||||
}
|
||||
@@ -446,14 +503,27 @@ class IssuesProcessor {
|
||||
IssuesProcessor._endIssueProcessing(issue);
|
||||
return; // Don't process exempt assignees
|
||||
}
|
||||
// Should this issue be marked stale?
|
||||
const shouldBeStale = !IssuesProcessor._updatedSince(issue.updated_at, daysBeforeStale);
|
||||
// Determine if this issue needs to be marked stale first
|
||||
if (!issue.isStale) {
|
||||
issueLogger.info(`This $$type is not stale`);
|
||||
const updatedAtDate = new Date(issue.updated_at);
|
||||
const shouldIgnoreUpdates = new ignore_updates_1.IgnoreUpdates(this.options, issue).shouldIgnoreUpdates();
|
||||
// Should this issue be marked as stale?
|
||||
let shouldBeStale;
|
||||
// Ignore the last update and only use the creation date
|
||||
if (shouldIgnoreUpdates) {
|
||||
shouldBeStale = !IssuesProcessor._updatedSince(issue.created_at, daysBeforeStale);
|
||||
}
|
||||
// Use the last update to check if we need to stale
|
||||
else {
|
||||
shouldBeStale = !IssuesProcessor._updatedSince(issue.updated_at, daysBeforeStale);
|
||||
}
|
||||
if (shouldBeStale) {
|
||||
issueLogger.info(`This $$type should be stale based on the last update date the ${get_humanized_date_1.getHumanizedDate(updatedAtDate)} (${logger_service_1.LoggerService.cyan(issue.updated_at)})`);
|
||||
if (shouldIgnoreUpdates) {
|
||||
issueLogger.info(`This $$type should be stale based on the creation date the ${get_humanized_date_1.getHumanizedDate(new Date(issue.created_at))} (${logger_service_1.LoggerService.cyan(issue.created_at)})`);
|
||||
}
|
||||
else {
|
||||
issueLogger.info(`This $$type should be stale based on the last update date the ${get_humanized_date_1.getHumanizedDate(new Date(issue.updated_at))} (${logger_service_1.LoggerService.cyan(issue.updated_at)})`);
|
||||
}
|
||||
if (shouldMarkAsStale) {
|
||||
issueLogger.info(`This $$type should be marked as stale based on the option ${issueLogger.createOptionLink(this._getDaysBeforeStaleUsedOptionName(issue))} (${logger_service_1.LoggerService.cyan(daysBeforeStale)})`);
|
||||
yield this._markStale(issue, staleMessage, staleLabel, skipMessage);
|
||||
@@ -465,7 +535,12 @@ class IssuesProcessor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
issueLogger.info(`This $$type should not be stale based on the last update date the ${get_humanized_date_1.getHumanizedDate(updatedAtDate)} (${logger_service_1.LoggerService.cyan(issue.updated_at)})`);
|
||||
if (shouldIgnoreUpdates) {
|
||||
issueLogger.info(`This $$type should not be stale based on the creation date the ${get_humanized_date_1.getHumanizedDate(new Date(issue.created_at))} (${logger_service_1.LoggerService.cyan(issue.created_at)})`);
|
||||
}
|
||||
else {
|
||||
issueLogger.info(`This $$type should not be stale based on the last update date the ${get_humanized_date_1.getHumanizedDate(new Date(issue.updated_at))} (${logger_service_1.LoggerService.cyan(issue.updated_at)})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Process the issue if it was marked stale
|
||||
@@ -1729,6 +1804,9 @@ var Option;
|
||||
Option["EnableStatistics"] = "enable-statistics";
|
||||
Option["LabelsToRemoveWhenUnstale"] = "labels-to-remove-when-unstale";
|
||||
Option["LabelsToAddWhenUnstale"] = "labels-to-add-when-unstale";
|
||||
Option["IgnoreUpdates"] = "ignore-updates";
|
||||
Option["IgnoreIssueUpdates"] = "ignore-issue-updates";
|
||||
Option["IgnorePrUpdates"] = "ignore-pr-updates";
|
||||
})(Option = exports.Option || (exports.Option = {}));
|
||||
|
||||
|
||||
@@ -2013,8 +2091,8 @@ function _getAndValidateArgs() {
|
||||
anyOfPrLabels: core.getInput('any-of-pr-labels'),
|
||||
operationsPerRun: parseInt(core.getInput('operations-per-run', { required: true })),
|
||||
removeStaleWhenUpdated: !(core.getInput('remove-stale-when-updated') === 'false'),
|
||||
removeIssueStaleWhenUpdated: _toOptionalBoolean(core.getInput('remove-issue-stale-when-updated')),
|
||||
removePrStaleWhenUpdated: _toOptionalBoolean(core.getInput('remove-pr-stale-when-updated')),
|
||||
removeIssueStaleWhenUpdated: _toOptionalBoolean('remove-issue-stale-when-updated'),
|
||||
removePrStaleWhenUpdated: _toOptionalBoolean('remove-pr-stale-when-updated'),
|
||||
debugOnly: core.getInput('debug-only') === 'true',
|
||||
ascending: core.getInput('ascending') === 'true',
|
||||
deleteBranch: core.getInput('delete-branch') === 'true',
|
||||
@@ -2035,7 +2113,10 @@ function _getAndValidateArgs() {
|
||||
exemptAllPrAssignees: _toOptionalBoolean('exempt-all-pr-assignees'),
|
||||
enableStatistics: core.getInput('enable-statistics') === 'true',
|
||||
labelsToRemoveWhenUnstale: core.getInput('labels-to-remove-when-unstale'),
|
||||
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale')
|
||||
labelsToAddWhenUnstale: core.getInput('labels-to-add-when-unstale'),
|
||||
ignoreUpdates: core.getInput('ignore-updates') === 'true',
|
||||
ignoreIssueUpdates: _toOptionalBoolean('ignore-issue-updates'),
|
||||
ignorePrUpdates: _toOptionalBoolean('ignore-pr-updates')
|
||||
};
|
||||
for (const numberInput of [
|
||||
'days-before-stale',
|
||||
@@ -2066,6 +2147,17 @@ function processOutput(staledIssues, closedIssues) {
|
||||
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description
|
||||
* From an argument name, get the value as an optional boolean
|
||||
* This is very useful for all the arguments that override others
|
||||
* It will allow us to easily use the original one when the return value is `undefined`
|
||||
* Which is different from `true` or `false` that consider the argument as set
|
||||
*
|
||||
* @param {Readonly<string>} argumentName The name of the argument to check
|
||||
*
|
||||
* @returns {boolean | undefined} The value matching the given argument name
|
||||
*/
|
||||
function _toOptionalBoolean(argumentName) {
|
||||
const argument = core.getInput(argumentName);
|
||||
if (argument === 'true') {
|
||||
|
||||
Reference in New Issue
Block a user