feat: remove the days-before-stale option
BREAKING CHANGE: The option days-before-stale was removed
This commit is contained in:
parent
6299c36a0d
commit
bab816b473
|
@ -12,7 +12,8 @@ jobs:
|
|||
id: stale
|
||||
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'
|
||||
days-before-stale: 30
|
||||
days-before-issue-stale: 30
|
||||
days-before-pr-stale: 30
|
||||
days-before-issue-close: 5
|
||||
days-before-pr-close: 5
|
||||
exempt-issue-labels: 'blocked,must,should,keep'
|
||||
|
|
69
README.md
69
README.md
|
@ -31,9 +31,8 @@ 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-issue-stale](#days-before-issue-stale) | Idle number of days before marking issues stale | `60` |
|
||||
| [days-before-pr-stale](#days-before-pr-stale) | Idle number of days before marking PRs stale | `60` |
|
||||
| [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` |
|
||||
| [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 }}`
|
||||
|
||||
#### 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 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.
|
||||
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.
|
||||
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.
|
||||
The idle number of days before marking the issues as stale (by adding a label).
|
||||
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 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) 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.
|
||||
|
||||
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)
|
||||
- [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)
|
||||
|
||||
A comment can also be added to notify about the stale and is defined by these two 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:
|
||||
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:
|
||||
|
||||
- [exempt-issue-labels](#exempt-issue-labels)
|
||||
- [exempt-pr-labels](#exempt-pr-labels)
|
||||
- [only-issue-labels](#only-issue-labels)
|
||||
- [only-pr-labels](#only-pr-labels)
|
||||
- [any-of-issue-labels](#any-of-issue-labels)
|
||||
- [any-of-pr-labels](#any-of-pr-labels)
|
||||
- [start-date](#start-date)
|
||||
- [exempt-issue-milestones](#exempt-issue-milestones)
|
||||
- [exempt-pr-milestones](#exempt-pr-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)
|
||||
- [exempt-all-pr-assignees](#exempt-all-pr-assignees)
|
||||
- [ignore-issue-updates](#ignore-issue-updates)
|
||||
- [ignore-pr-updates](#ignore-pr-updates)
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -455,7 +455,8 @@ describe('any-of-pr-labels option', (): void => {
|
|||
class IssuesProcessorBuilder {
|
||||
private _options: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 0
|
||||
daysBeforeIssueStale: 0,
|
||||
daysBeforePrStale: 0
|
||||
};
|
||||
private _issues: Issue[] = [];
|
||||
|
||||
|
|
|
@ -6,9 +6,8 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
|||
stalePrMessage: 'This PR is stale',
|
||||
closeIssueMessage: 'This issue is being closed',
|
||||
closePrMessage: 'This PR is being closed',
|
||||
daysBeforeStale: 1,
|
||||
daysBeforeIssueStale: NaN,
|
||||
daysBeforePrStale: NaN,
|
||||
daysBeforeIssueStale: 1,
|
||||
daysBeforePrStale: 1,
|
||||
daysBeforeIssueClose: 30,
|
||||
daysBeforePrClose: 30,
|
||||
staleIssueLabel: 'Stale',
|
||||
|
|
|
@ -347,7 +347,7 @@ test('processing an issue with no label will not make it stale if days-before-st
|
|||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueMessage: '',
|
||||
daysBeforeStale: -1
|
||||
daysBeforeIssueStale: -1
|
||||
};
|
||||
const TestIssueList: Issue[] = [
|
||||
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 = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueMessage: '',
|
||||
daysBeforeStale: -1,
|
||||
daysBeforeIssueStale: -1
|
||||
};
|
||||
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 () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 1; // closes after 6 days
|
||||
const lastUpdate = new Date();
|
||||
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 () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 1; // closes after 6 days
|
||||
const lastUpdate = new Date();
|
||||
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 () => {
|
||||
const opts = {...DefaultProcessorOptions};
|
||||
opts.daysBeforeStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueStale = 5; // stale after 5 days
|
||||
opts.daysBeforeIssueClose = 20; // closes after 25 days
|
||||
const lastUpdate = new Date();
|
||||
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 () => {
|
||||
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.staleIssueMessage = '';
|
||||
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 () => {
|
||||
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.staleIssueMessage = 'dummy issue message';
|
||||
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 () => {
|
||||
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.stalePrMessage = '';
|
||||
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 () => {
|
||||
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.stalePrMessage = 'dummy pr message';
|
||||
const lastUpdate = new Date();
|
||||
|
@ -1797,7 +1796,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
|||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 3
|
||||
};
|
||||
const issueDate = new Date();
|
||||
|
@ -1823,7 +1821,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
|||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 2
|
||||
};
|
||||
const issueDate = new Date();
|
||||
|
@ -1849,7 +1846,6 @@ test('processing an issue opened since 2 days and with the option "daysBeforeIss
|
|||
expect.assertions(2);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 1
|
||||
};
|
||||
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);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforePrStale: 3
|
||||
};
|
||||
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);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforePrStale: 2
|
||||
};
|
||||
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);
|
||||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
|
@ -2080,7 +2076,7 @@ test('processing an issue stale since less than the daysBeforeStale with a stale
|
|||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueLabel: 'stale-label',
|
||||
daysBeforeStale: 30,
|
||||
daysBeforeIssueStale: 30,
|
||||
daysBeforeIssueClose: 7,
|
||||
closeIssueMessage: 'close message',
|
||||
removeStaleWhenUpdated: false
|
||||
|
@ -2121,7 +2117,7 @@ test('processing an issue stale since less than the daysBeforeStale without a st
|
|||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueLabel: 'stale-label',
|
||||
daysBeforeStale: 30,
|
||||
daysBeforeIssueStale: 30,
|
||||
daysBeforeIssueClose: 7,
|
||||
closeIssueMessage: 'close message',
|
||||
removeStaleWhenUpdated: false
|
||||
|
@ -2161,7 +2157,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
|
|||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
stalePrMessage: 'This PR is stale',
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
|
@ -2196,7 +2192,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
|
|||
const opts: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
stalePrMessage: '',
|
||||
daysBeforeStale: 10,
|
||||
daysBeforeIssueStale: 10,
|
||||
daysBeforePrStale: 1
|
||||
};
|
||||
const issueDate = new Date();
|
||||
|
|
|
@ -455,7 +455,8 @@ describe('only-pr-labels option', (): void => {
|
|||
class IssuesProcessorBuilder {
|
||||
private _options: IIssuesProcessorOptions = {
|
||||
...DefaultProcessorOptions,
|
||||
daysBeforeStale: 0
|
||||
daysBeforeIssueStale: 0,
|
||||
daysBeforePrStale: 0
|
||||
};
|
||||
private _issues: Issue[] = [];
|
||||
|
||||
|
|
10
action.yml
10
action.yml
|
@ -18,15 +18,13 @@ inputs:
|
|||
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.'
|
||||
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:
|
||||
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
|
||||
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
|
||||
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.'
|
||||
|
|
|
@ -409,8 +409,8 @@ class IssuesProcessor {
|
|||
? this.options.stalePrMessage.length === 0
|
||||
: this.options.staleIssueMessage.length === 0;
|
||||
const daysBeforeStale = issue.isPullRequest
|
||||
? this._getDaysBeforePrStale()
|
||||
: this._getDaysBeforeIssueStale();
|
||||
? this.options.daysBeforePrStale
|
||||
: this.options.daysBeforeIssueStale;
|
||||
if (issue.state === 'closed') {
|
||||
issueLogger.info(`Skipping this $$type because it is closed`);
|
||||
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)})`);
|
||||
}
|
||||
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);
|
||||
issue.isStale = true; // This issue is now considered stale
|
||||
issueLogger.info(`This $$type is now stale`);
|
||||
}
|
||||
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 {
|
||||
|
@ -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) {
|
||||
if (issue.isPullRequest) {
|
||||
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) {
|
||||
this.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) {
|
||||
if (issue.isPullRequest) {
|
||||
if (is_boolean_1.isBoolean(this.options.removePrStaleWhenUpdated)) {
|
||||
|
@ -1735,7 +1715,6 @@ var Option;
|
|||
Option["StalePrMessage"] = "stale-pr-message";
|
||||
Option["CloseIssueMessage"] = "close-issue-message";
|
||||
Option["ClosePrMessage"] = "close-pr-message";
|
||||
Option["DaysBeforeStale"] = "days-before-stale";
|
||||
Option["DaysBeforeIssueStale"] = "days-before-issue-stale";
|
||||
Option["DaysBeforePrStale"] = "days-before-pr-stale";
|
||||
Option["DaysBeforeIssueClose"] = "days-before-issue-close";
|
||||
|
@ -2036,9 +2015,8 @@ function _getAndValidateArgs() {
|
|||
stalePrMessage: core.getInput('stale-pr-message'),
|
||||
closeIssueMessage: core.getInput('close-issue-message'),
|
||||
closePrMessage: core.getInput('close-pr-message'),
|
||||
daysBeforeStale: parseInt(core.getInput('days-before-stale', { required: true })),
|
||||
daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')),
|
||||
daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')),
|
||||
daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale', { required: true })),
|
||||
daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale', { required: true })),
|
||||
daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close', { required: true })),
|
||||
daysBeforePrClose: parseInt(core.getInput('days-before-pr-close', { required: true })),
|
||||
staleIssueLabel: core.getInput('stale-issue-label', { required: true }),
|
||||
|
@ -2077,7 +2055,8 @@ function _getAndValidateArgs() {
|
|||
exemptDraftPr: core.getInput('exempt-draft-pr') === 'true'
|
||||
};
|
||||
for (const numberInput of [
|
||||
'days-before-stale',
|
||||
'days-before-issue-stale',
|
||||
'days-before-pr-stale',
|
||||
'days-before-issue-close',
|
||||
'days-before-pr-close',
|
||||
'operations-per-run'
|
||||
|
|
|
@ -21,7 +21,6 @@ describe('Issue', (): void => {
|
|||
daysBeforeIssueStale: 0,
|
||||
daysBeforePrClose: 0,
|
||||
daysBeforePrStale: 0,
|
||||
daysBeforeStale: 0,
|
||||
debugOnly: false,
|
||||
deleteBranch: false,
|
||||
exemptIssueLabels: '',
|
||||
|
|
|
@ -207,8 +207,8 @@ export class IssuesProcessor {
|
|||
? this.options.stalePrMessage.length === 0
|
||||
: this.options.staleIssueMessage.length === 0;
|
||||
const daysBeforeStale: number = issue.isPullRequest
|
||||
? this._getDaysBeforePrStale()
|
||||
: this._getDaysBeforeIssueStale();
|
||||
? this.options.daysBeforePrStale
|
||||
: this.options.daysBeforeIssueStale;
|
||||
|
||||
if (issue.state === 'closed') {
|
||||
issueLogger.info(`Skipping this $$type because it is closed`);
|
||||
|
@ -461,7 +461,7 @@ export class IssuesProcessor {
|
|||
if (shouldMarkAsStale) {
|
||||
issueLogger.info(
|
||||
`This $$type should be marked as stale based on the option ${issueLogger.createOptionLink(
|
||||
this._getDaysBeforeStaleUsedOptionName(issue)
|
||||
IssuesProcessor._getDaysBeforeStaleUsedOptionName(issue)
|
||||
)} (${LoggerService.cyan(daysBeforeStale)})`
|
||||
);
|
||||
await this._markStale(issue, staleMessage, staleLabel, skipMessage);
|
||||
|
@ -470,7 +470,7 @@ export class IssuesProcessor {
|
|||
} else {
|
||||
issueLogger.info(
|
||||
`This $$type should not be marked as stale based on the option ${issueLogger.createOptionLink(
|
||||
this._getDaysBeforeStaleUsedOptionName(issue)
|
||||
IssuesProcessor._getDaysBeforeStaleUsedOptionName(issue)
|
||||
)} (${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 {
|
||||
if (issue.isPullRequest) {
|
||||
return this.options.onlyPrLabels;
|
||||
|
@ -1117,36 +1105,17 @@ export class IssuesProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
private _consumeIssueOperation(issue: Readonly<Issue>): void {
|
||||
this.operations.consumeOperation();
|
||||
issue.operations.consumeOperation();
|
||||
}
|
||||
|
||||
private _getDaysBeforeStaleUsedOptionName(
|
||||
private static _getDaysBeforeStaleUsedOptionName(
|
||||
issue: Readonly<Issue>
|
||||
):
|
||||
| Option.DaysBeforeStale
|
||||
| Option.DaysBeforeIssueStale
|
||||
| Option.DaysBeforePrStale {
|
||||
): Option.DaysBeforeIssueStale | Option.DaysBeforePrStale {
|
||||
return issue.isPullRequest
|
||||
? this._getDaysBeforePrStaleUsedOptionName()
|
||||
: this._getDaysBeforeIssueStaleUsedOptionName();
|
||||
}
|
||||
|
||||
private _getDaysBeforeIssueStaleUsedOptionName():
|
||||
| Option.DaysBeforeStale
|
||||
| Option.DaysBeforeIssueStale {
|
||||
return isNaN(this.options.daysBeforeIssueStale)
|
||||
? Option.DaysBeforeStale
|
||||
? Option.DaysBeforePrStale
|
||||
: Option.DaysBeforeIssueStale;
|
||||
}
|
||||
|
||||
private _getDaysBeforePrStaleUsedOptionName():
|
||||
| Option.DaysBeforeStale
|
||||
| Option.DaysBeforePrStale {
|
||||
return isNaN(this.options.daysBeforePrStale)
|
||||
? Option.DaysBeforeStale
|
||||
: Option.DaysBeforePrStale;
|
||||
private _consumeIssueOperation(issue: Readonly<Issue>): void {
|
||||
this.operations.consumeOperation();
|
||||
issue.operations.consumeOperation();
|
||||
}
|
||||
|
||||
private _getRemoveStaleWhenUpdatedUsedOptionName(
|
||||
|
|
|
@ -4,7 +4,6 @@ export enum Option {
|
|||
StalePrMessage = 'stale-pr-message',
|
||||
CloseIssueMessage = 'close-issue-message',
|
||||
ClosePrMessage = 'close-pr-message',
|
||||
DaysBeforeStale = 'days-before-stale',
|
||||
DaysBeforeIssueStale = 'days-before-issue-stale',
|
||||
DaysBeforePrStale = 'days-before-pr-stale',
|
||||
DaysBeforeIssueClose = 'days-before-issue-close',
|
||||
|
|
|
@ -6,9 +6,8 @@ export interface IIssuesProcessorOptions {
|
|||
stalePrMessage: string;
|
||||
closeIssueMessage: string;
|
||||
closePrMessage: string;
|
||||
daysBeforeStale: number;
|
||||
daysBeforeIssueStale: number; // Could be NaN
|
||||
daysBeforePrStale: number; // Could be NaN
|
||||
daysBeforeIssueStale: number;
|
||||
daysBeforePrStale: number;
|
||||
daysBeforeIssueClose: number;
|
||||
daysBeforePrClose: number;
|
||||
staleIssueLabel: string;
|
||||
|
|
12
src/main.ts
12
src/main.ts
|
@ -28,11 +28,12 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||
stalePrMessage: core.getInput('stale-pr-message'),
|
||||
closeIssueMessage: core.getInput('close-issue-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})
|
||||
),
|
||||
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(
|
||||
core.getInput('days-before-issue-close', {required: true})
|
||||
),
|
||||
|
@ -87,7 +88,8 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||
};
|
||||
|
||||
for (const numberInput of [
|
||||
'days-before-stale',
|
||||
'days-before-issue-stale',
|
||||
'days-before-pr-stale',
|
||||
'days-before-issue-close',
|
||||
'days-before-pr-close',
|
||||
'operations-per-run'
|
||||
|
|
Loading…
Reference in New Issue