feat: remove the exempt-all-milestones option

BREAKING CHANGE:
The option exempt-all-milestones was removed
This commit is contained in:
TESTELIN Geoffrey 2021-10-08 19:19:07 +02:00
parent 4665995b65
commit 315391885d
No known key found for this signature in database
GPG Key ID: 05D28E8D8E8E52DA
11 changed files with 1752 additions and 4146 deletions

116
README.md
View File

@ -28,55 +28,54 @@ You can find more information about the required permissions under the correspon
Every argument is optional.
| Input | Description | Default |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------ | --------------------- |
| [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` |
| [days-before-stale](#days-before-stale) | Idle number of days before marking issues/PRs stale | `60` |
| [days-before-issue-stale](#days-before-issue-stale) | Override [days-before-stale](#days-before-stale) for issues only | |
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
| [days-before-close](#days-before-close) | Idle number of days before closing stale issues/PRs | `7` |
| [days-before-issue-close](#days-before-issue-close) | Override [days-before-close](#days-before-close) for issues only | |
| [days-before-pr-close](#days-before-pr-close) | Override [days-before-close](#days-before-close) for PRs only | |
| [stale-issue-message](#stale-issue-message) | Comment on the staled issues | |
| [stale-pr-message](#stale-pr-message) | Comment on the staled PRs | |
| [close-issue-message](#close-issue-message) | Comment on the staled issues while closed | |
| [close-pr-message](#close-pr-message) | Comment on the staled PRs while closed | |
| [stale-issue-label](#stale-issue-label) | Label to apply on staled issues | `Stale` |
| [close-issue-label](#close-issue-label) | Label to apply on closed issues | |
| [stale-pr-label](#stale-pr-label) | Label to apply on staled PRs | `Stale` |
| [close-pr-label](#close-pr-label) | Label to apply on closed PRs | |
| [exempt-issue-labels](#exempt-issue-labels) | Labels on issues exempted from stale | |
| [exempt-pr-labels](#exempt-pr-labels) | Labels on PRs exempted from stale | |
| [only-labels](#only-labels) | Only issues/PRs with ALL these labels are checked | |
| [only-issue-labels](#only-issue-labels) | Override [only-labels](#only-labels) for issues only | |
| [only-pr-labels](#only-pr-labels) | Override [only-labels](#only-labels) for PRs only | |
| [any-of-labels](#any-of-labels) | Only issues/PRs with ANY of these labels are checked | |
| [any-of-issue-labels](#any-of-issue-labels) | Override [any-of-labels](#any-of-labels) for issues only | |
| [any-of-pr-labels](#any-of-pr-labels) | Override [any-of-labels](#any-of-labels) for PRs only | |
| [operations-per-run](#operations-per-run) | Max number of operations per run | `30` |
| [remove-stale-when-updated](#remove-stale-when-updated) | Remove stale label from issues/PRs on updates | `true` |
| [remove-issue-stale-when-updated](#remove-issue-stale-when-updated) | Remove stale label from issues on updates/comments | |
| [remove-pr-stale-when-updated](#remove-pr-stale-when-updated) | Remove stale label from PRs on updates/comments | |
| [labels-to-add-when-unstale](#labels-to-add-when-unstale) | Add specified labels from issues/PRs when they become unstale | |
| [labels-to-remove-when-unstale](#labels-to-remove-when-unstale) | Remove specified labels from issues/PRs when they become unstale | |
| [debug-only](#debug-only) | Dry-run | `false` |
| [ascending](#ascending) | Order to get issues/PRs | `false` |
| [start-date](#start-date) | Skip stale action for issues/PRs created before it | |
| [delete-branch](#delete-branch) | Delete branch after closing a stale PR | `false` |
| [exempt-milestones](#exempt-milestones) | Milestones on issues/PRs exempted from stale | |
| [exempt-issue-milestones](#exempt-issue-milestones) | Override [exempt-milestones](#exempt-milestones) for issues only | |
| [exempt-pr-milestones](#exempt-pr-milestones) | Override [exempt-milestones](#exempt-milestones) for PRs only | |
| [exempt-all-milestones](#exempt-all-milestones) | Exempt all issues/PRs with milestones from stale | `false` |
| [exempt-all-issue-milestones](#exempt-all-issue-milestones) | Override [exempt-all-milestones](#exempt-all-milestones) for issues only | |
| [exempt-all-pr-milestones](#exempt-all-pr-milestones) | Override [exempt-all-milestones](#exempt-all-milestones) for PRs only | |
| [exempt-issue-assignees](#exempt-issue-assignees) | Assignees on issues exempted from stale | |
| [exempt-pr-assignees](#exempt-pr-assignees) | Assignees on PRs exempted from stale | |
| [exempt-all-issue-assignees](#exempt-all-issue-assignees) | Exempt all issues with assignees from stale | `false` |
| [exempt-all-pr-assignees](#exempt-all-pr-assignees) | Exempt all PRs with assignees from stale | `false` |
| [exempt-draft-pr](#exempt-draft-pr) | Skip the stale action for draft PRs | `false` |
| [enable-statistics](#enable-statistics) | Display statistics in the logs | `true` |
| [ignore-issue-updates](#ignore-issue-updates) | Any update (update/comment) can reset the stale idle time on the issues | `false` |
| [ignore-pr-updates](#ignore-pr-updates) | Any update (update/comment) can reset the stale idle time on the PRs | `false` |
| Input | Description | Default |
| ------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------- | ------- |
| [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` |
| [days-before-stale](#days-before-stale) | Idle number of days before marking issues/PRs stale | `60` |
| [days-before-issue-stale](#days-before-issue-stale) | Override [days-before-stale](#days-before-stale) for issues only | |
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
| [days-before-close](#days-before-close) | Idle number of days before closing stale issues/PRs | `7` |
| [days-before-issue-close](#days-before-issue-close) | Override [days-before-close](#days-before-close) for issues only | |
| [days-before-pr-close](#days-before-pr-close) | Override [days-before-close](#days-before-close) for PRs only | |
| [stale-issue-message](#stale-issue-message) | Comment on the staled issues | |
| [stale-pr-message](#stale-pr-message) | Comment on the staled PRs | |
| [close-issue-message](#close-issue-message) | Comment on the staled issues while closed | |
| [close-pr-message](#close-pr-message) | Comment on the staled PRs while closed | |
| [stale-issue-label](#stale-issue-label) | Label to apply on staled issues | `Stale` |
| [close-issue-label](#close-issue-label) | Label to apply on closed issues | |
| [stale-pr-label](#stale-pr-label) | Label to apply on staled PRs | `Stale` |
| [close-pr-label](#close-pr-label) | Label to apply on closed PRs | |
| [exempt-issue-labels](#exempt-issue-labels) | Labels on issues exempted from stale | |
| [exempt-pr-labels](#exempt-pr-labels) | Labels on PRs exempted from stale | |
| [only-labels](#only-labels) | Only issues/PRs with ALL these labels are checked | |
| [only-issue-labels](#only-issue-labels) | Override [only-labels](#only-labels) for issues only | |
| [only-pr-labels](#only-pr-labels) | Override [only-labels](#only-labels) for PRs only | |
| [any-of-labels](#any-of-labels) | Only issues/PRs with ANY of these labels are checked | |
| [any-of-issue-labels](#any-of-issue-labels) | Override [any-of-labels](#any-of-labels) for issues only | |
| [any-of-pr-labels](#any-of-pr-labels) | Override [any-of-labels](#any-of-labels) for PRs only | |
| [operations-per-run](#operations-per-run) | Max number of operations per run | `30` |
| [remove-stale-when-updated](#remove-stale-when-updated) | Remove stale label from issues/PRs on updates | `true` |
| [remove-issue-stale-when-updated](#remove-issue-stale-when-updated) | Remove stale label from issues on updates/comments | |
| [remove-pr-stale-when-updated](#remove-pr-stale-when-updated) | Remove stale label from PRs on updates/comments | |
| [labels-to-add-when-unstale](#labels-to-add-when-unstale) | Add specified labels from issues/PRs when they become unstale | |
| [labels-to-remove-when-unstale](#labels-to-remove-when-unstale) | Remove specified labels from issues/PRs when they become unstale | |
| [debug-only](#debug-only) | Dry-run | `false` |
| [ascending](#ascending) | Order to get issues/PRs | `false` |
| [start-date](#start-date) | Skip stale action for issues/PRs created before it | |
| [delete-branch](#delete-branch) | Delete branch after closing a stale PR | `false` |
| [exempt-milestones](#exempt-milestones) | Milestones on issues/PRs exempted from stale | |
| [exempt-issue-milestones](#exempt-issue-milestones) | Override [exempt-milestones](#exempt-milestones) for issues only | |
| [exempt-pr-milestones](#exempt-pr-milestones) | Override [exempt-milestones](#exempt-milestones) for PRs only | |
| [exempt-all-issue-milestones](#exempt-all-issue-milestones) | Exempt all issues with milestones from stale | | `false` |
| [exempt-all-pr-milestones](#exempt-all-pr-milestones) | Exempt all PRs with milestones from stale | | `false` |
| [exempt-issue-assignees](#exempt-issue-assignees) | Assignees on issues exempted from stale | |
| [exempt-pr-assignees](#exempt-pr-assignees) | Assignees on PRs exempted from stale | |
| [exempt-all-issue-assignees](#exempt-all-issue-assignees) | Exempt all issues with assignees from stale | `false` |
| [exempt-all-pr-assignees](#exempt-all-pr-assignees) | Exempt all PRs with assignees from stale | `false` |
| [exempt-draft-pr](#exempt-draft-pr) | Skip the stale action for draft PRs | `false` |
| [enable-statistics](#enable-statistics) | Display statistics in the logs | `true` |
| [ignore-issue-updates](#ignore-issue-updates) | Any update (update/comment) can reset the stale idle time on the issues | `false` |
| [ignore-pr-updates](#ignore-pr-updates) | Any update (update/comment) can reset the stale idle time on the PRs | `false` |
### List of output options
@ -122,7 +121,8 @@ You can fine tune which issues or pull requests should be marked as stale based
- [any-of-labels](#any-of-labels)
- [start-date](#start-date)
- [exempt-milestones](#exempt-milestones)
- [exempt-all-milestones](#exempt-all-milestones)
- [exempt-all-issue-milestones](#exempt-all-issue-milestones)
- [exempt-all-pr-milestones](#exempt-all-pr-milestones)
- [exempt-issue-assignees](#exempt-issue-assignees)
- [exempt-pr-assignees](#exempt-pr-assignees)
- [exempt-all-issue-assignees](#exempt-all-issue-assignees)
@ -412,25 +412,21 @@ Override [exempt-milestones](#exempt-milestones) but only to process the pull re
Default value: unset
#### exempt-all-milestones
#### exempt-all-issue-milestones
If set to `true`, the issues or the pull requests with a milestone will not be marked as stale automatically.
If set to `true`, the issues with a milestone will not be marked as stale automatically.
Priority over [exempt-milestones](#exempt-milestones).
Default value: `false`
#### exempt-all-issue-milestones
Override [exempt-all-milestones](#exempt-all-milestones) but only to exempt the issues with a milestone to be marked as stale automatically.
Default value: unset
#### exempt-all-pr-milestones
Override [exempt-all-milestones](#exempt-all-milestones) but only to exempt the pull requests with a milestone to be marked as stale automatically.
If set to `true`, the pull requests with a milestone will not be marked as stale automatically.
Default value: unset
Priority over [exempt-milestones](#exempt-milestones).
Default value: `false`
#### exempt-issue-assignees

View File

@ -35,9 +35,8 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
exemptMilestones: '',
exemptIssueMilestones: '',
exemptPrMilestones: '',
exemptAllMilestones: false,
exemptAllIssueMilestones: undefined,
exemptAllPrMilestones: undefined,
exemptAllIssueMilestones: false,
exemptAllPrMilestones: false,
exemptAssignees: '',
exemptIssueAssignees: '',
exemptPrAssignees: '',

File diff suppressed because it is too large Load Diff

View File

@ -72,17 +72,13 @@ inputs:
description: 'The milestones that mean a pull request is exempt from being marked as stale. Separate multiple milestones with commas (eg. "milestone1,milestone2"). Override "exempt-milestones" option regarding only the pull requests.'
default: ''
required: false
exempt-all-milestones:
description: 'Exempt all issues and pull requests with milestones from being marked as stale. Default to false.'
exempt-all-issue-milestones:
description: 'Exempt all issues with milestones from being marked as stale. Default to false.'
default: 'false'
required: false
exempt-all-issue-milestones:
description: 'Exempt all issues with milestones from being marked as stale. Override "exempt-all-milestones" option regarding only the issues.'
default: ''
required: false
exempt-all-pr-milestones:
description: 'Exempt all pull requests with milestones from being marked as stale. Override "exempt-all-milestones" option regarding only the pull requests.'
default: ''
description: 'Exempt all pull requests with milestones from being marked as stale. Default to false.'
default: 'false'
required: false
only-labels:
description: 'Only issues or pull requests with all of these labels are checked if stale. Defaults to `` (disabled) and can be a comma-separated list of labels.'

34
dist/index.js vendored
View File

@ -1315,36 +1315,20 @@ class Milestones {
return false;
}
_shouldExemptAllIssueMilestones() {
if (this._options.exemptAllIssueMilestones === true) {
if (this._options.exemptAllIssueMilestones) {
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllIssueMilestones)} is enabled. Any milestone on this $$type will skip the stale process`);
return true;
}
else if (this._options.exemptAllIssueMilestones === false) {
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllIssueMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
return false;
}
this._logExemptAllMilestonesOption();
return this._options.exemptAllMilestones;
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllIssueMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
return false;
}
_shouldExemptAllPullRequestMilestones() {
if (this._options.exemptAllPrMilestones === true) {
if (this._options.exemptAllPrMilestones) {
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllPrMilestones)} is enabled. Any milestone on this $$type will skip the stale process`);
return true;
}
else if (this._options.exemptAllPrMilestones === false) {
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllPrMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
return false;
}
this._logExemptAllMilestonesOption();
return this._options.exemptAllMilestones;
}
_logExemptAllMilestonesOption() {
if (this._options.exemptAllMilestones) {
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllMilestones)} is enabled. Any milestone on this $$type will skip the stale process`);
}
else {
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
}
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllPrMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
return false;
}
_logSkip() {
this._issueLogger.info(logger_service_1.LoggerService.white('└──'), 'Skip the milestones checks');
@ -1814,7 +1798,6 @@ var Option;
Option["ExemptMilestones"] = "exempt-milestones";
Option["ExemptIssueMilestones"] = "exempt-issue-milestones";
Option["ExemptPrMilestones"] = "exempt-pr-milestones";
Option["ExemptAllMilestones"] = "exempt-all-milestones";
Option["ExemptAllIssueMilestones"] = "exempt-all-issue-milestones";
Option["ExemptAllPrMilestones"] = "exempt-all-pr-milestones";
Option["ExemptIssueAssignees"] = "exempt-issue-assignees";
@ -2122,9 +2105,8 @@ function _getAndValidateArgs() {
exemptMilestones: core.getInput('exempt-milestones'),
exemptIssueMilestones: core.getInput('exempt-issue-milestones'),
exemptPrMilestones: core.getInput('exempt-pr-milestones'),
exemptAllMilestones: core.getInput('exempt-all-milestones') === 'true',
exemptAllIssueMilestones: _toOptionalBoolean('exempt-all-issue-milestones'),
exemptAllPrMilestones: _toOptionalBoolean('exempt-all-pr-milestones'),
exemptAllIssueMilestones: core.getInput('exempt-all-issue-milestones') === 'true',
exemptAllPrMilestones: core.getInput('exempt-all-pr-milestones') === 'true',
exemptIssueAssignees: core.getInput('exempt-issue-assignees'),
exemptPrAssignees: core.getInput('exempt-pr-assignees'),
exemptAllIssueAssignees: core.getInput('exempt-all-issue-assignees') === 'true',

View File

@ -46,9 +46,8 @@ describe('Issue', (): void => {
exemptMilestones: '',
exemptIssueMilestones: '',
exemptPrMilestones: '',
exemptAllMilestones: false,
exemptAllIssueMilestones: undefined,
exemptAllPrMilestones: undefined,
exemptAllIssueMilestones: false,
exemptAllPrMilestones: false,
exemptIssueAssignees: '',
exemptPrAssignees: '',
exemptAllIssueAssignees: false,

File diff suppressed because it is too large Load Diff

View File

@ -1,297 +1,273 @@
import deburr from 'lodash.deburr';
import {Option} from '../enums/option';
import {wordsToList} from '../functions/words-to-list';
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
import {Issue} from './issue';
import {IssueLogger} from './loggers/issue-logger';
import {LoggerService} from '../services/logger.service';
type CleanMilestone = string;
export class Milestones {
private static _cleanMilestone(milestone: Readonly<string>): CleanMilestone {
return deburr(milestone.toLowerCase());
}
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);
}
shouldExemptMilestones(): boolean {
if (!this._issue.milestone) {
this._issueLogger.info('This $$type has no milestone');
this._logSkip();
return false;
}
if (this._shouldExemptAllMilestones()) {
this._issueLogger.info(
LoggerService.white('└──'),
'Skipping this $$type because it has a milestone'
);
return true;
}
const exemptMilestones: string[] = this._getExemptMilestones();
if (exemptMilestones.length === 0) {
this._issueLogger.info(
LoggerService.white('├──'),
`No milestone option was specified to skip the stale process for this $$type`
);
this._logSkip();
return false;
}
this._issueLogger.info(
LoggerService.white('├──'),
`Found ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length > 1 ? 's' : ''
} that can exempt stale on this $$type`
);
const hasExemptMilestone: boolean = exemptMilestones.some(
(exemptMilestone: Readonly<string>): boolean =>
this._hasMilestone(exemptMilestone)
);
if (!hasExemptMilestone) {
this._issueLogger.info(
LoggerService.white('├──'),
'No milestone on this $$type can exempt the stale process'
);
this._logSkip();
} else {
this._issueLogger.info(
LoggerService.white('└──'),
'Skipping this $$type because it has an exempt milestone'
);
}
return hasExemptMilestone;
}
private _getExemptMilestones(): string[] {
return this._issue.isPullRequest
? this._getExemptPullRequestMilestones()
: this._getExemptIssueMilestones();
}
private _getExemptIssueMilestones(): string[] {
if (this._options.exemptIssueMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptIssueMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
if (this._options.exemptMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
return [];
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptIssueMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptIssueMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
private _getExemptPullRequestMilestones(): string[] {
if (this._options.exemptPrMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptPrMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
if (this._options.exemptMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
return [];
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptPrMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptPrMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
private _hasMilestone(milestone: Readonly<string>): boolean {
if (!this._issue.milestone) {
return false;
}
const cleanMilestone: CleanMilestone =
Milestones._cleanMilestone(milestone);
const isSameMilestone: boolean =
cleanMilestone ===
Milestones._cleanMilestone(this._issue.milestone.title);
if (isSameMilestone) {
this._issueLogger.info(
LoggerService.white('├──'),
`The milestone "${LoggerService.cyan(
milestone
)}" is set on this $$type and is an exempt milestone`
);
}
return isSameMilestone;
}
private _shouldExemptAllMilestones(): boolean {
if (this._issue.milestone) {
return this._issue.isPullRequest
? this._shouldExemptAllPullRequestMilestones()
: this._shouldExemptAllIssueMilestones();
}
return false;
}
private _shouldExemptAllIssueMilestones(): boolean {
if (this._options.exemptAllIssueMilestones === true) {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllIssueMilestones
)} is enabled. Any milestone on this $$type will skip the stale process`
);
return true;
} else if (this._options.exemptAllIssueMilestones === false) {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllIssueMilestones
)} is disabled. Only some specific milestones on this $$type will skip the stale process`
);
return false;
}
this._logExemptAllMilestonesOption();
return this._options.exemptAllMilestones;
}
private _shouldExemptAllPullRequestMilestones(): boolean {
if (this._options.exemptAllPrMilestones === true) {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllPrMilestones
)} is enabled. Any milestone on this $$type will skip the stale process`
);
return true;
} else if (this._options.exemptAllPrMilestones === false) {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllPrMilestones
)} is disabled. Only some specific milestones on this $$type will skip the stale process`
);
return false;
}
this._logExemptAllMilestonesOption();
return this._options.exemptAllMilestones;
}
private _logExemptAllMilestonesOption(): void {
if (this._options.exemptAllMilestones) {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllMilestones
)} is enabled. Any milestone on this $$type will skip the stale process`
);
} else {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllMilestones
)} is disabled. Only some specific milestones on this $$type will skip the stale process`
);
}
}
private _logSkip(): void {
this._issueLogger.info(
LoggerService.white('└──'),
'Skip the milestones checks'
);
}
}
import deburr from 'lodash.deburr';
import {Option} from '../enums/option';
import {wordsToList} from '../functions/words-to-list';
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
import {Issue} from './issue';
import {IssueLogger} from './loggers/issue-logger';
import {LoggerService} from '../services/logger.service';
type CleanMilestone = string;
export class Milestones {
private static _cleanMilestone(milestone: Readonly<string>): CleanMilestone {
return deburr(milestone.toLowerCase());
}
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);
}
shouldExemptMilestones(): boolean {
if (!this._issue.milestone) {
this._issueLogger.info('This $$type has no milestone');
this._logSkip();
return false;
}
if (this._shouldExemptAllMilestones()) {
this._issueLogger.info(
LoggerService.white('└──'),
'Skipping this $$type because it has a milestone'
);
return true;
}
const exemptMilestones: string[] = this._getExemptMilestones();
if (exemptMilestones.length === 0) {
this._issueLogger.info(
LoggerService.white('├──'),
`No milestone option was specified to skip the stale process for this $$type`
);
this._logSkip();
return false;
}
this._issueLogger.info(
LoggerService.white('├──'),
`Found ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length > 1 ? 's' : ''
} that can exempt stale on this $$type`
);
const hasExemptMilestone: boolean = exemptMilestones.some(
(exemptMilestone: Readonly<string>): boolean =>
this._hasMilestone(exemptMilestone)
);
if (!hasExemptMilestone) {
this._issueLogger.info(
LoggerService.white('├──'),
'No milestone on this $$type can exempt the stale process'
);
this._logSkip();
} else {
this._issueLogger.info(
LoggerService.white('└──'),
'Skipping this $$type because it has an exempt milestone'
);
}
return hasExemptMilestone;
}
private _getExemptMilestones(): string[] {
return this._issue.isPullRequest
? this._getExemptPullRequestMilestones()
: this._getExemptIssueMilestones();
}
private _getExemptIssueMilestones(): string[] {
if (this._options.exemptIssueMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptIssueMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
if (this._options.exemptMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
return [];
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptIssueMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptIssueMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
private _getExemptPullRequestMilestones(): string[] {
if (this._options.exemptPrMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptPrMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
if (this._options.exemptMilestones === '') {
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is disabled. No specific milestone can skip the stale process for this $$type`
);
return [];
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
const exemptMilestones: string[] = wordsToList(
this._options.exemptPrMilestones
);
this._issueLogger.info(
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptPrMilestones
)} is set. ${LoggerService.cyan(exemptMilestones.length)} milestone${
exemptMilestones.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
return exemptMilestones;
}
private _hasMilestone(milestone: Readonly<string>): boolean {
if (!this._issue.milestone) {
return false;
}
const cleanMilestone: CleanMilestone =
Milestones._cleanMilestone(milestone);
const isSameMilestone: boolean =
cleanMilestone ===
Milestones._cleanMilestone(this._issue.milestone.title);
if (isSameMilestone) {
this._issueLogger.info(
LoggerService.white('├──'),
`The milestone "${LoggerService.cyan(
milestone
)}" is set on this $$type and is an exempt milestone`
);
}
return isSameMilestone;
}
private _shouldExemptAllMilestones(): boolean {
if (this._issue.milestone) {
return this._issue.isPullRequest
? this._shouldExemptAllPullRequestMilestones()
: this._shouldExemptAllIssueMilestones();
}
return false;
}
private _shouldExemptAllIssueMilestones(): boolean {
if (this._options.exemptAllIssueMilestones) {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllIssueMilestones
)} is enabled. Any milestone on this $$type will skip the stale process`
);
return true;
}
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllIssueMilestones
)} is disabled. Only some specific milestones on this $$type will skip the stale process`
);
return false;
}
private _shouldExemptAllPullRequestMilestones(): boolean {
if (this._options.exemptAllPrMilestones) {
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllPrMilestones
)} is enabled. Any milestone on this $$type will skip the stale process`
);
return true;
}
this._issueLogger.info(
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAllPrMilestones
)} is disabled. Only some specific milestones on this $$type will skip the stale process`
);
return false;
}
private _logSkip(): void {
this._issueLogger.info(
LoggerService.white('└──'),
'Skip the milestones checks'
);
}
}

View File

@ -31,7 +31,6 @@ export enum Option {
ExemptMilestones = 'exempt-milestones',
ExemptIssueMilestones = 'exempt-issue-milestones',
ExemptPrMilestones = 'exempt-pr-milestones',
ExemptAllMilestones = 'exempt-all-milestones',
ExemptAllIssueMilestones = 'exempt-all-issue-milestones',
ExemptAllPrMilestones = 'exempt-all-pr-milestones',
ExemptIssueAssignees = 'exempt-issue-assignees',

View File

@ -35,9 +35,8 @@ export interface IIssuesProcessorOptions {
exemptMilestones: string;
exemptIssueMilestones: string;
exemptPrMilestones: string;
exemptAllMilestones: boolean;
exemptAllIssueMilestones: boolean | undefined;
exemptAllPrMilestones: boolean | undefined;
exemptAllIssueMilestones: boolean;
exemptAllPrMilestones: boolean;
exemptIssueAssignees: string;
exemptPrAssignees: string;
exemptAllIssueAssignees: boolean;

View File

@ -72,9 +72,9 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
exemptMilestones: core.getInput('exempt-milestones'),
exemptIssueMilestones: core.getInput('exempt-issue-milestones'),
exemptPrMilestones: core.getInput('exempt-pr-milestones'),
exemptAllMilestones: core.getInput('exempt-all-milestones') === 'true',
exemptAllIssueMilestones: _toOptionalBoolean('exempt-all-issue-milestones'),
exemptAllPrMilestones: _toOptionalBoolean('exempt-all-pr-milestones'),
exemptAllIssueMilestones:
core.getInput('exempt-all-issue-milestones') === 'true',
exemptAllPrMilestones: core.getInput('exempt-all-pr-milestones') === 'true',
exemptIssueAssignees: core.getInput('exempt-issue-assignees'),
exemptPrAssignees: core.getInput('exempt-pr-assignees'),
exemptAllIssueAssignees: