feat: remove the days-before-stale option

BREAKING CHANGE:
The option days-before-stale was removed
This commit is contained in:
TESTELIN Geoffrey 2021-10-08 21:06:12 +02:00
parent 6299c36a0d
commit bab816b473
No known key found for this signature in database
GPG Key ID: 05D28E8D8E8E52DA
13 changed files with 94 additions and 150 deletions

View File

@ -12,7 +12,8 @@ jobs:
id: stale id: stale
with: with:
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days' stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
days-before-stale: 30 days-before-issue-stale: 30
days-before-pr-stale: 30
days-before-issue-close: 5 days-before-issue-close: 5
days-before-pr-close: 5 days-before-pr-close: 5
exempt-issue-labels: 'blocked,must,should,keep' exempt-issue-labels: 'blocked,must,should,keep'

View File

@ -31,9 +31,8 @@ Every argument is optional.
| Input | Description | Default | | Input | Description | Default |
| ------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------- | | ------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------- |
| [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` | | [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) | Idle number of days before marking issues 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) | Idle number of days before marking PRs stale | `60` |
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
| [days-before-issue-close](#days-before-issue-close) | Idle number of days before closing stale issues | `7` | | [days-before-issue-close](#days-before-issue-close) | Idle number of days before closing stale issues | `7` |
| [days-before-pr-close](#days-before-pr-close) | Idle number of days before closing stale PRs | `7` | | [days-before-pr-close](#days-before-pr-close) | Idle number of days before closing stale PRs | `7` |
| [stale-issue-message](#stale-issue-message) | Comment on the staled issues | | | [stale-issue-message](#stale-issue-message) | Comment on the staled issues | |
@ -89,59 +88,61 @@ Under the hood, it uses the [@actions/github](https://www.npmjs.com/package/@act
Default value: `${{ github.token }}` Default value: `${{ github.token }}`
#### days-before-stale #### days-before-issue-stale
The idle number of days before marking the issues or the pull requests as stale (by adding a label). The idle number of days before marking the issues as stale (by adding a label).
The issues or the pull requests will be marked as stale if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days. The issues will be marked as stale if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days.
It means that any updates made, or any comments added to the issues or to the pull requests will restart the counter of days before marking as stale. It means that any updates made, or any comments added to the issues will restart the counter of days before marking as stale.
However, if you wish to ignore this behaviour so that the creation date (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`) only matters, you can disable the [ignore-issue-updates](#ignore-issue-updates) and [ignore-pr-updates](#ignore-pr-updates) options. However, if you wish to ignore this behaviour so that the creation date (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`) only matters, you can disable the [ignore-issue-updates](#ignore-issue-updates) option.
If set to a negative number like `-1`, no issues or pull requests will be marked as stale automatically. If set to a negative number like `-1`, no issues will be marked as stale automatically.
In that case, you can still add the stale label manually to mark as stale. In that case, you can still add the stale label manually to mark as stale.
The label used to stale is defined by these two options: The label used to stale is defined by this option: [stale-pr-label](#stale-pr-label)
- [stale-issue-label](#stale-issue-label) A comment can also be added to notify about the stale and is defined by this option: [stale-pr-message](#stale-pr-message)
- [stale-pr-label](#stale-pr-label)
A comment can also be added to notify about the stale and is defined by these two options: You can fine tune which issues should be marked as stale based on the milestones, the assignees, the creation date and the missing/present labels from these options:
- [stale-issue-message](#stale-issue-message)
- [stale-pr-message](#stale-pr-message)
You can fine tune which issues or pull requests should be marked as stale based on the milestones, the assignees, the creation date and the missing/present labels from these options:
- [exempt-issue-labels](#exempt-issue-labels) - [exempt-issue-labels](#exempt-issue-labels)
- [exempt-pr-labels](#exempt-pr-labels)
- [only-issue-labels](#only-issue-labels) - [only-issue-labels](#only-issue-labels)
- [only-pr-labels](#only-pr-labels)
- [any-of-issue-labels](#any-of-issue-labels) - [any-of-issue-labels](#any-of-issue-labels)
- [any-of-pr-labels](#any-of-pr-labels)
- [start-date](#start-date) - [start-date](#start-date)
- [exempt-issue-milestones](#exempt-issue-milestones) - [exempt-issue-milestones](#exempt-issue-milestones)
- [exempt-pr-milestones](#exempt-pr-milestones)
- [exempt-all-issue-milestones](#exempt-all-issue-milestones) - [exempt-all-issue-milestones](#exempt-all-issue-milestones)
- [exempt-all-pr-milestones](#exempt-all-pr-milestones)
- [exempt-issue-assignees](#exempt-issue-assignees) - [exempt-issue-assignees](#exempt-issue-assignees)
- [exempt-pr-assignees](#exempt-pr-assignees)
- [exempt-all-issue-assignees](#exempt-all-issue-assignees) - [exempt-all-issue-assignees](#exempt-all-issue-assignees)
- [exempt-all-pr-assignees](#exempt-all-pr-assignees)
- [ignore-issue-updates](#ignore-issue-updates) - [ignore-issue-updates](#ignore-issue-updates)
- [ignore-pr-updates](#ignore-pr-updates)
Default value: `60` Default value: `60`
#### days-before-issue-stale
Useful to override [days-before-stale](#days-before-stale) but only for the idle number of days before marking the issues as stale.
Default value: unset
#### days-before-pr-stale #### days-before-pr-stale
Useful to override [days-before-stale](#days-before-stale) but only for the idle number of days before marking the pull requests as stale. The idle number of days before marking the pull requests as stale (by adding a label).
The pull requests will be marked as stale if the last update (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) is older than the idle number of days.
It means that any updates made, or any comments added to the pull requests will restart the counter of days before marking as stale.
However, if you wish to ignore this behaviour so that the creation date (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `created_at`) only matters, you can disable the [ignore-pr-updates](#ignore-pr-updates) option.
Default value: unset If set to a negative number like `-1`, no pull requests will be marked as stale automatically.
In that case, you can still add the stale label manually to mark as stale.
The label used to stale is defined by this option: [stale-pr-label](#stale-pr-label)
A comment can also be added to notify about the stale and is defined by this option: [stale-pr-message](#stale-pr-message)
You can fine tune which pull requests should be marked as stale based on the milestones, the assignees, the creation date and the missing/present labels from these options:
- [exempt-pr-labels](#exempt-pr-labels)
- [only-pr-labels](#only-pr-labels)
- [any-of-pr-labels](#any-of-pr-labels)
- [start-date](#start-date)
- [exempt-pr-milestones](#exempt-pr-milestones)
- [exempt-all-pr-milestones](#exempt-all-pr-milestones)
- [exempt-pr-assignees](#exempt-pr-assignees)
- [exempt-all-pr-assignees](#exempt-all-pr-assignees)
- [ignore-pr-updates](#ignore-pr-updates)
Default value: `60`
#### days-before-issue-close #### days-before-issue-close

View File

@ -455,7 +455,8 @@ describe('any-of-pr-labels option', (): void => {
class IssuesProcessorBuilder { class IssuesProcessorBuilder {
private _options: IIssuesProcessorOptions = { private _options: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 0 daysBeforeIssueStale: 0,
daysBeforePrStale: 0
}; };
private _issues: Issue[] = []; private _issues: Issue[] = [];

View File

@ -6,9 +6,8 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
stalePrMessage: 'This PR is stale', stalePrMessage: 'This PR is stale',
closeIssueMessage: 'This issue is being closed', closeIssueMessage: 'This issue is being closed',
closePrMessage: 'This PR is being closed', closePrMessage: 'This PR is being closed',
daysBeforeStale: 1, daysBeforeIssueStale: 1,
daysBeforeIssueStale: NaN, daysBeforePrStale: 1,
daysBeforePrStale: NaN,
daysBeforeIssueClose: 30, daysBeforeIssueClose: 30,
daysBeforePrClose: 30, daysBeforePrClose: 30,
staleIssueLabel: 'Stale', staleIssueLabel: 'Stale',

View File

@ -347,7 +347,7 @@ test('processing an issue with no label will not make it stale if days-before-st
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
staleIssueMessage: '', staleIssueMessage: '',
daysBeforeStale: -1 daysBeforeIssueStale: -1
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z') generateIssue(opts, 1, 'An issue with no label', '2020-01-01T17:00:00Z')
@ -370,7 +370,6 @@ test('processing an issue with no label will not make it stale if days-before-st
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
staleIssueMessage: '', staleIssueMessage: '',
daysBeforeStale: -1,
daysBeforeIssueStale: -1 daysBeforeIssueStale: -1
}; };
const TestIssueList: Issue[] = [ const TestIssueList: Issue[] = [
@ -1304,7 +1303,7 @@ test('stale label containing a space should be removed if a comment was added to
test('stale issues should not be closed until after the closed number of days', async () => { test('stale issues should not be closed until after the closed number of days', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 1; // closes after 6 days opts.daysBeforeIssueClose = 1; // closes after 6 days
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 5); lastUpdate.setDate(lastUpdate.getDate() - 5);
@ -1335,7 +1334,7 @@ test('stale issues should not be closed until after the closed number of days',
test('stale issues should be closed if the closed nubmer of days (additive) is also passed', async () => { test('stale issues should be closed if the closed nubmer of days (additive) is also passed', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 1; // closes after 6 days opts.daysBeforeIssueClose = 1; // closes after 6 days
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 7); lastUpdate.setDate(lastUpdate.getDate() - 7);
@ -1367,7 +1366,7 @@ test('stale issues should be closed if the closed nubmer of days (additive) is a
test('stale issues should not be closed until after the closed number of days (long)', async () => { test('stale issues should not be closed until after the closed number of days (long)', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days opts.daysBeforeIssueClose = 20; // closes after 25 days
const lastUpdate = new Date(); const lastUpdate = new Date();
lastUpdate.setDate(lastUpdate.getDate() - 10); lastUpdate.setDate(lastUpdate.getDate() - 10);
@ -1398,7 +1397,7 @@ test('stale issues should not be closed until after the closed number of days (l
test('skips stale message on issues when stale-issue-message is empty', async () => { test('skips stale message on issues when stale-issue-message is empty', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.staleIssueMessage = ''; opts.staleIssueMessage = '';
const lastUpdate = new Date(); const lastUpdate = new Date();
@ -1442,7 +1441,7 @@ test('skips stale message on issues when stale-issue-message is empty', async ()
test('send stale message on issues when stale-issue-message is not empty', async () => { test('send stale message on issues when stale-issue-message is not empty', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.staleIssueMessage = 'dummy issue message'; opts.staleIssueMessage = 'dummy issue message';
const lastUpdate = new Date(); const lastUpdate = new Date();
@ -1486,7 +1485,7 @@ test('send stale message on issues when stale-issue-message is not empty', async
test('skips stale message on prs when stale-pr-message is empty', async () => { test('skips stale message on prs when stale-pr-message is empty', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.stalePrMessage = ''; opts.stalePrMessage = '';
const lastUpdate = new Date(); const lastUpdate = new Date();
@ -1530,7 +1529,7 @@ test('skips stale message on prs when stale-pr-message is empty', async () => {
test('send stale message on prs when stale-pr-message is not empty', async () => { test('send stale message on prs when stale-pr-message is not empty', async () => {
const opts = {...DefaultProcessorOptions}; const opts = {...DefaultProcessorOptions};
opts.daysBeforeStale = 5; // stale after 5 days opts.daysBeforeIssueStale = 5; // stale after 5 days
opts.daysBeforeIssueClose = 20; // closes after 25 days opts.daysBeforeIssueClose = 20; // closes after 25 days
opts.stalePrMessage = 'dummy pr message'; opts.stalePrMessage = 'dummy pr message';
const lastUpdate = new Date(); const lastUpdate = new Date();
@ -1797,7 +1796,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
expect.assertions(2); expect.assertions(2);
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 3 daysBeforeIssueStale: 3
}; };
const issueDate = new Date(); const issueDate = new Date();
@ -1823,7 +1821,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
expect.assertions(2); expect.assertions(2);
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 2 daysBeforeIssueStale: 2
}; };
const issueDate = new Date(); const issueDate = new Date();
@ -1849,7 +1846,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
expect.assertions(2); expect.assertions(2);
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 10,
daysBeforeIssueStale: 1 daysBeforeIssueStale: 1
}; };
const issueDate = new Date(); const issueDate = new Date();
@ -1875,7 +1871,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
expect.assertions(2); expect.assertions(2);
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 10, daysBeforeIssueStale: 10,
daysBeforePrStale: 3 daysBeforePrStale: 3
}; };
const issueDate = new Date(); const issueDate = new Date();
@ -1908,7 +1904,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
expect.assertions(2); expect.assertions(2);
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 10, daysBeforeIssueStale: 10,
daysBeforePrStale: 2 daysBeforePrStale: 2
}; };
const issueDate = new Date(); const issueDate = new Date();
@ -1941,7 +1937,7 @@ test('processing a pull request opened since 2 days and with the option "daysBef
expect.assertions(2); expect.assertions(2);
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 10, daysBeforeIssueStale: 10,
daysBeforePrStale: 1 daysBeforePrStale: 1
}; };
const issueDate = new Date(); const issueDate = new Date();
@ -2080,7 +2076,7 @@ test('processing an issue stale since less than the daysBeforeStale with a stale
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
staleIssueLabel: 'stale-label', staleIssueLabel: 'stale-label',
daysBeforeStale: 30, daysBeforeIssueStale: 30,
daysBeforeIssueClose: 7, daysBeforeIssueClose: 7,
closeIssueMessage: 'close message', closeIssueMessage: 'close message',
removeStaleWhenUpdated: false removeStaleWhenUpdated: false
@ -2121,7 +2117,7 @@ test('processing an issue stale since less than the daysBeforeStale without a st
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
staleIssueLabel: 'stale-label', staleIssueLabel: 'stale-label',
daysBeforeStale: 30, daysBeforeIssueStale: 30,
daysBeforeIssueClose: 7, daysBeforeIssueClose: 7,
closeIssueMessage: 'close message', closeIssueMessage: 'close message',
removeStaleWhenUpdated: false removeStaleWhenUpdated: false
@ -2161,7 +2157,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
stalePrMessage: 'This PR is stale', stalePrMessage: 'This PR is stale',
daysBeforeStale: 10, daysBeforeIssueStale: 10,
daysBeforePrStale: 1 daysBeforePrStale: 1
}; };
const issueDate = new Date(); const issueDate = new Date();
@ -2196,7 +2192,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
const opts: IIssuesProcessorOptions = { const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
stalePrMessage: '', stalePrMessage: '',
daysBeforeStale: 10, daysBeforeIssueStale: 10,
daysBeforePrStale: 1 daysBeforePrStale: 1
}; };
const issueDate = new Date(); const issueDate = new Date();

View File

@ -455,7 +455,8 @@ describe('only-pr-labels option', (): void => {
class IssuesProcessorBuilder { class IssuesProcessorBuilder {
private _options: IIssuesProcessorOptions = { private _options: IIssuesProcessorOptions = {
...DefaultProcessorOptions, ...DefaultProcessorOptions,
daysBeforeStale: 0 daysBeforeIssueStale: 0,
daysBeforePrStale: 0
}; };
private _issues: Issue[] = []; private _issues: Issue[] = [];

View File

@ -18,15 +18,13 @@ inputs:
close-pr-message: close-pr-message:
description: 'The message to post on the pull request when closing it. If none provided, will not comment when closing a pull requests.' description: 'The message to post on the pull request when closing it. If none provided, will not comment when closing a pull requests.'
required: false required: false
days-before-stale:
description: 'The number of days old an issue or a pull request can be before marking it stale. Set to -1 to never mark issues or pull requests as stale automatically.'
required: false
default: '60'
days-before-issue-stale: days-before-issue-stale:
description: 'The number of days old an issue can be before marking it stale. Set to -1 to never mark issues as stale automatically. Override "days-before-stale" option regarding only the issues.' description: 'The number of days old an issue can be before marking it stale. Set to -1 to never mark issues or pull requests as stale automatically.'
default: '60'
required: false required: false
days-before-pr-stale: days-before-pr-stale:
description: 'The number of days old a pull request can be before marking it stale. Set to -1 to never mark pull requests as stale automatically. Override "days-before-stale" option regarding only the pull requests.' description: 'The number of days old a pull request can be before marking it stale. Set to -1 to never mark issues or pull requests as stale automatically.'
default: '60'
required: false required: false
days-before-issue-close: days-before-issue-close:
description: 'The number of days to wait to close an issue after it being marked stale. Set to -1 to never close stale issues or pull requests.' description: 'The number of days to wait to close an issue after it being marked stale. Set to -1 to never close stale issues or pull requests.'

47
dist/index.js vendored
View File

@ -409,8 +409,8 @@ class IssuesProcessor {
? this.options.stalePrMessage.length === 0 ? this.options.stalePrMessage.length === 0
: this.options.staleIssueMessage.length === 0; : this.options.staleIssueMessage.length === 0;
const daysBeforeStale = issue.isPullRequest const daysBeforeStale = issue.isPullRequest
? this._getDaysBeforePrStale() ? this.options.daysBeforePrStale
: this._getDaysBeforeIssueStale(); : this.options.daysBeforeIssueStale;
if (issue.state === 'closed') { if (issue.state === 'closed') {
issueLogger.info(`Skipping this $$type because it is closed`); issueLogger.info(`Skipping this $$type because it is closed`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
@ -542,13 +542,13 @@ class IssuesProcessor {
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)})`); 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) { 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)})`); issueLogger.info(`This $$type should be marked as stale based on the option ${issueLogger.createOptionLink(IssuesProcessor._getDaysBeforeStaleUsedOptionName(issue))} (${logger_service_1.LoggerService.cyan(daysBeforeStale)})`);
yield this._markStale(issue, staleMessage, staleLabel, skipMessage); yield this._markStale(issue, staleMessage, staleLabel, skipMessage);
issue.isStale = true; // This issue is now considered stale issue.isStale = true; // This issue is now considered stale
issueLogger.info(`This $$type is now stale`); issueLogger.info(`This $$type is now stale`);
} }
else { else {
issueLogger.info(`This $$type should not be marked as stale based on the option ${issueLogger.createOptionLink(this._getDaysBeforeStaleUsedOptionName(issue))} (${logger_service_1.LoggerService.cyan(daysBeforeStale)})`); issueLogger.info(`This $$type should not be marked as stale based on the option ${issueLogger.createOptionLink(IssuesProcessor._getDaysBeforeStaleUsedOptionName(issue))} (${logger_service_1.LoggerService.cyan(daysBeforeStale)})`);
} }
} }
else { else {
@ -890,16 +890,6 @@ class IssuesProcessor {
} }
}); });
} }
_getDaysBeforeIssueStale() {
return isNaN(this.options.daysBeforeIssueStale)
? this.options.daysBeforeStale
: this.options.daysBeforeIssueStale;
}
_getDaysBeforePrStale() {
return isNaN(this.options.daysBeforePrStale)
? this.options.daysBeforeStale
: this.options.daysBeforePrStale;
}
_getOnlyLabels(issue) { _getOnlyLabels(issue) {
if (issue.isPullRequest) { if (issue.isPullRequest) {
return this.options.onlyPrLabels; return this.options.onlyPrLabels;
@ -992,25 +982,15 @@ class IssuesProcessor {
} }
}); });
} }
static _getDaysBeforeStaleUsedOptionName(issue) {
return issue.isPullRequest
? option_1.Option.DaysBeforePrStale
: option_1.Option.DaysBeforeIssueStale;
}
_consumeIssueOperation(issue) { _consumeIssueOperation(issue) {
this.operations.consumeOperation(); this.operations.consumeOperation();
issue.operations.consumeOperation(); issue.operations.consumeOperation();
} }
_getDaysBeforeStaleUsedOptionName(issue) {
return issue.isPullRequest
? this._getDaysBeforePrStaleUsedOptionName()
: this._getDaysBeforeIssueStaleUsedOptionName();
}
_getDaysBeforeIssueStaleUsedOptionName() {
return isNaN(this.options.daysBeforeIssueStale)
? option_1.Option.DaysBeforeStale
: option_1.Option.DaysBeforeIssueStale;
}
_getDaysBeforePrStaleUsedOptionName() {
return isNaN(this.options.daysBeforePrStale)
? option_1.Option.DaysBeforeStale
: option_1.Option.DaysBeforePrStale;
}
_getRemoveStaleWhenUpdatedUsedOptionName(issue) { _getRemoveStaleWhenUpdatedUsedOptionName(issue) {
if (issue.isPullRequest) { if (issue.isPullRequest) {
if (is_boolean_1.isBoolean(this.options.removePrStaleWhenUpdated)) { if (is_boolean_1.isBoolean(this.options.removePrStaleWhenUpdated)) {
@ -1735,7 +1715,6 @@ var Option;
Option["StalePrMessage"] = "stale-pr-message"; Option["StalePrMessage"] = "stale-pr-message";
Option["CloseIssueMessage"] = "close-issue-message"; Option["CloseIssueMessage"] = "close-issue-message";
Option["ClosePrMessage"] = "close-pr-message"; Option["ClosePrMessage"] = "close-pr-message";
Option["DaysBeforeStale"] = "days-before-stale";
Option["DaysBeforeIssueStale"] = "days-before-issue-stale"; Option["DaysBeforeIssueStale"] = "days-before-issue-stale";
Option["DaysBeforePrStale"] = "days-before-pr-stale"; Option["DaysBeforePrStale"] = "days-before-pr-stale";
Option["DaysBeforeIssueClose"] = "days-before-issue-close"; Option["DaysBeforeIssueClose"] = "days-before-issue-close";
@ -2036,9 +2015,8 @@ function _getAndValidateArgs() {
stalePrMessage: core.getInput('stale-pr-message'), stalePrMessage: core.getInput('stale-pr-message'),
closeIssueMessage: core.getInput('close-issue-message'), closeIssueMessage: core.getInput('close-issue-message'),
closePrMessage: core.getInput('close-pr-message'), closePrMessage: core.getInput('close-pr-message'),
daysBeforeStale: parseInt(core.getInput('days-before-stale', { required: true })), daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale', { required: true })),
daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')), daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale', { required: true })),
daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')),
daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close', { required: true })), daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close', { required: true })),
daysBeforePrClose: parseInt(core.getInput('days-before-pr-close', { required: true })), daysBeforePrClose: parseInt(core.getInput('days-before-pr-close', { required: true })),
staleIssueLabel: core.getInput('stale-issue-label', { required: true }), staleIssueLabel: core.getInput('stale-issue-label', { required: true }),
@ -2077,7 +2055,8 @@ function _getAndValidateArgs() {
exemptDraftPr: core.getInput('exempt-draft-pr') === 'true' exemptDraftPr: core.getInput('exempt-draft-pr') === 'true'
}; };
for (const numberInput of [ for (const numberInput of [
'days-before-stale', 'days-before-issue-stale',
'days-before-pr-stale',
'days-before-issue-close', 'days-before-issue-close',
'days-before-pr-close', 'days-before-pr-close',
'operations-per-run' 'operations-per-run'

View File

@ -21,7 +21,6 @@ describe('Issue', (): void => {
daysBeforeIssueStale: 0, daysBeforeIssueStale: 0,
daysBeforePrClose: 0, daysBeforePrClose: 0,
daysBeforePrStale: 0, daysBeforePrStale: 0,
daysBeforeStale: 0,
debugOnly: false, debugOnly: false,
deleteBranch: false, deleteBranch: false,
exemptIssueLabels: '', exemptIssueLabels: '',

View File

@ -207,8 +207,8 @@ export class IssuesProcessor {
? this.options.stalePrMessage.length === 0 ? this.options.stalePrMessage.length === 0
: this.options.staleIssueMessage.length === 0; : this.options.staleIssueMessage.length === 0;
const daysBeforeStale: number = issue.isPullRequest const daysBeforeStale: number = issue.isPullRequest
? this._getDaysBeforePrStale() ? this.options.daysBeforePrStale
: this._getDaysBeforeIssueStale(); : this.options.daysBeforeIssueStale;
if (issue.state === 'closed') { if (issue.state === 'closed') {
issueLogger.info(`Skipping this $$type because it is closed`); issueLogger.info(`Skipping this $$type because it is closed`);
@ -461,7 +461,7 @@ export class IssuesProcessor {
if (shouldMarkAsStale) { if (shouldMarkAsStale) {
issueLogger.info( issueLogger.info(
`This $$type should be marked as stale based on the option ${issueLogger.createOptionLink( `This $$type should be marked as stale based on the option ${issueLogger.createOptionLink(
this._getDaysBeforeStaleUsedOptionName(issue) IssuesProcessor._getDaysBeforeStaleUsedOptionName(issue)
)} (${LoggerService.cyan(daysBeforeStale)})` )} (${LoggerService.cyan(daysBeforeStale)})`
); );
await this._markStale(issue, staleMessage, staleLabel, skipMessage); await this._markStale(issue, staleMessage, staleLabel, skipMessage);
@ -470,7 +470,7 @@ export class IssuesProcessor {
} else { } else {
issueLogger.info( issueLogger.info(
`This $$type should not be marked as stale based on the option ${issueLogger.createOptionLink( `This $$type should not be marked as stale based on the option ${issueLogger.createOptionLink(
this._getDaysBeforeStaleUsedOptionName(issue) IssuesProcessor._getDaysBeforeStaleUsedOptionName(issue)
)} (${LoggerService.cyan(daysBeforeStale)})` )} (${LoggerService.cyan(daysBeforeStale)})`
); );
} }
@ -957,18 +957,6 @@ export class IssuesProcessor {
} }
} }
private _getDaysBeforeIssueStale(): number {
return isNaN(this.options.daysBeforeIssueStale)
? this.options.daysBeforeStale
: this.options.daysBeforeIssueStale;
}
private _getDaysBeforePrStale(): number {
return isNaN(this.options.daysBeforePrStale)
? this.options.daysBeforeStale
: this.options.daysBeforePrStale;
}
private _getOnlyLabels(issue: Issue): string { private _getOnlyLabels(issue: Issue): string {
if (issue.isPullRequest) { if (issue.isPullRequest) {
return this.options.onlyPrLabels; return this.options.onlyPrLabels;
@ -1117,36 +1105,17 @@ export class IssuesProcessor {
} }
} }
private _consumeIssueOperation(issue: Readonly<Issue>): void { private static _getDaysBeforeStaleUsedOptionName(
this.operations.consumeOperation();
issue.operations.consumeOperation();
}
private _getDaysBeforeStaleUsedOptionName(
issue: Readonly<Issue> issue: Readonly<Issue>
): ): Option.DaysBeforeIssueStale | Option.DaysBeforePrStale {
| Option.DaysBeforeStale
| Option.DaysBeforeIssueStale
| Option.DaysBeforePrStale {
return issue.isPullRequest return issue.isPullRequest
? this._getDaysBeforePrStaleUsedOptionName() ? Option.DaysBeforePrStale
: this._getDaysBeforeIssueStaleUsedOptionName();
}
private _getDaysBeforeIssueStaleUsedOptionName():
| Option.DaysBeforeStale
| Option.DaysBeforeIssueStale {
return isNaN(this.options.daysBeforeIssueStale)
? Option.DaysBeforeStale
: Option.DaysBeforeIssueStale; : Option.DaysBeforeIssueStale;
} }
private _getDaysBeforePrStaleUsedOptionName(): private _consumeIssueOperation(issue: Readonly<Issue>): void {
| Option.DaysBeforeStale this.operations.consumeOperation();
| Option.DaysBeforePrStale { issue.operations.consumeOperation();
return isNaN(this.options.daysBeforePrStale)
? Option.DaysBeforeStale
: Option.DaysBeforePrStale;
} }
private _getRemoveStaleWhenUpdatedUsedOptionName( private _getRemoveStaleWhenUpdatedUsedOptionName(

View File

@ -4,7 +4,6 @@ export enum Option {
StalePrMessage = 'stale-pr-message', StalePrMessage = 'stale-pr-message',
CloseIssueMessage = 'close-issue-message', CloseIssueMessage = 'close-issue-message',
ClosePrMessage = 'close-pr-message', ClosePrMessage = 'close-pr-message',
DaysBeforeStale = 'days-before-stale',
DaysBeforeIssueStale = 'days-before-issue-stale', DaysBeforeIssueStale = 'days-before-issue-stale',
DaysBeforePrStale = 'days-before-pr-stale', DaysBeforePrStale = 'days-before-pr-stale',
DaysBeforeIssueClose = 'days-before-issue-close', DaysBeforeIssueClose = 'days-before-issue-close',

View File

@ -6,9 +6,8 @@ export interface IIssuesProcessorOptions {
stalePrMessage: string; stalePrMessage: string;
closeIssueMessage: string; closeIssueMessage: string;
closePrMessage: string; closePrMessage: string;
daysBeforeStale: number; daysBeforeIssueStale: number;
daysBeforeIssueStale: number; // Could be NaN daysBeforePrStale: number;
daysBeforePrStale: number; // Could be NaN
daysBeforeIssueClose: number; daysBeforeIssueClose: number;
daysBeforePrClose: number; daysBeforePrClose: number;
staleIssueLabel: string; staleIssueLabel: string;

View File

@ -28,11 +28,12 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
stalePrMessage: core.getInput('stale-pr-message'), stalePrMessage: core.getInput('stale-pr-message'),
closeIssueMessage: core.getInput('close-issue-message'), closeIssueMessage: core.getInput('close-issue-message'),
closePrMessage: core.getInput('close-pr-message'), closePrMessage: core.getInput('close-pr-message'),
daysBeforeStale: parseInt( daysBeforeIssueStale: parseInt(
core.getInput('days-before-stale', {required: true}) core.getInput('days-before-issue-stale', {required: true})
),
daysBeforePrStale: parseInt(
core.getInput('days-before-pr-stale', {required: true})
), ),
daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')),
daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')),
daysBeforeIssueClose: parseInt( daysBeforeIssueClose: parseInt(
core.getInput('days-before-issue-close', {required: true}) core.getInput('days-before-issue-close', {required: true})
), ),
@ -87,7 +88,8 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
}; };
for (const numberInput of [ for (const numberInput of [
'days-before-stale', 'days-before-issue-stale',
'days-before-pr-stale',
'days-before-issue-close', 'days-before-issue-close',
'days-before-pr-close', 'days-before-pr-close',
'operations-per-run' 'operations-per-run'