mirror of
https://github.com/actions/stale.git
synced 2025-12-10 03:57:04 +00:00
* 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
91 lines
3.1 KiB
TypeScript
91 lines
3.1 KiB
TypeScript
import {Option} from '../enums/option';
|
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
|
import {Issue} from './issue';
|
|
import {IssueLogger} from './loggers/issue-logger';
|
|
|
|
export class IgnoreUpdates {
|
|
private readonly _options: IIssuesProcessorOptions;
|
|
private readonly _issue: Issue;
|
|
private readonly _issueLogger: IssueLogger;
|
|
|
|
constructor(options: Readonly<IIssuesProcessorOptions>, issue: Issue) {
|
|
this._options = options;
|
|
this._issue = issue;
|
|
this._issueLogger = new IssueLogger(issue);
|
|
}
|
|
|
|
shouldIgnoreUpdates(): boolean {
|
|
return this._shouldIgnoreUpdates();
|
|
}
|
|
|
|
private _shouldIgnoreUpdates(): boolean {
|
|
return this._issue.isPullRequest
|
|
? this._shouldIgnorePullRequestUpdates()
|
|
: this._shouldIgnoreIssueUpdates();
|
|
}
|
|
|
|
private _shouldIgnorePullRequestUpdates(): boolean {
|
|
if (this._options.ignorePrUpdates === true) {
|
|
this._issueLogger.info(
|
|
`The option ${this._issueLogger.createOptionLink(
|
|
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.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;
|
|
}
|
|
|
|
private _shouldIgnoreIssueUpdates(): boolean {
|
|
if (this._options.ignoreIssueUpdates === true) {
|
|
this._issueLogger.info(
|
|
`The option ${this._issueLogger.createOptionLink(
|
|
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.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;
|
|
}
|
|
|
|
private _logIgnoreUpdates(): void {
|
|
if (this._options.ignoreUpdates) {
|
|
this._issueLogger.info(
|
|
`The option ${this._issueLogger.createOptionLink(
|
|
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.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`
|
|
);
|
|
}
|
|
}
|
|
}
|