feat: remove the remove-stale-when-updated option
BREAKING CHANGE: The option remove-stale-when-updated was removed
This commit is contained in:
parent
bab816b473
commit
b9a40762bf
21
README.md
21
README.md
|
@ -50,9 +50,8 @@ Every argument is optional.
|
||||||
| [any-of-issue-labels](#any-of-issue-labels) | Only issues with ANY of these labels are checked | |
|
| [any-of-issue-labels](#any-of-issue-labels) | Only issues with ANY of these labels are checked | |
|
||||||
| [any-of-pr-labels](#any-of-pr-labels) | Only PRs with ANY of these labels are checked | |
|
| [any-of-pr-labels](#any-of-pr-labels) | Only PRs with ANY of these labels are checked | |
|
||||||
| [operations-per-run](#operations-per-run) | Max number of operations per run | `30` |
|
| [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 | `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 | `true` |
|
||||||
| [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-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 | |
|
| [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` |
|
| [debug-only](#debug-only) | Dry-run | `false` |
|
||||||
|
@ -315,25 +314,19 @@ Only the [actor](#repo-token) and the batch of issues (100 per batch) will consu
|
||||||
|
|
||||||
Default value: `30`
|
Default value: `30`
|
||||||
|
|
||||||
#### remove-stale-when-updated
|
|
||||||
|
|
||||||
Automatically remove the stale label when the issues or the pull requests are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
|
||||||
|
|
||||||
Default value: `true`
|
|
||||||
Required Permission: `issues: write` and `pull-requests: write`
|
|
||||||
|
|
||||||
#### remove-issue-stale-when-updated
|
#### remove-issue-stale-when-updated
|
||||||
|
|
||||||
Override [remove-stale-when-updated](#remove-stale-when-updated) but only to automatically remove the stale label when the issues are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
Automatically remove the stale label when the issues are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
||||||
|
|
||||||
Default value: unset
|
Default value: `true`
|
||||||
Required Permission: `issues: write`
|
Required Permission: `issues: write`
|
||||||
|
|
||||||
#### remove-pr-stale-when-updated
|
#### remove-pr-stale-when-updated
|
||||||
|
|
||||||
Override [remove-stale-when-updated](#remove-stale-when-updated) but only to automatically remove the stale label when the pull requests are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
Automatically remove the stale label when the pull requests are updated (based on [GitHub issue](https://docs.github.com/en/rest/reference/issues) field `updated_at`) or commented.
|
||||||
|
|
||||||
Default value: unset
|
Default value: `true`
|
||||||
|
Required Permission: `pull-requests: write`
|
||||||
|
|
||||||
#### labels-to-add-when-unstale
|
#### labels-to-add-when-unstale
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,8 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||||
anyOfPrLabels: '',
|
anyOfPrLabels: '',
|
||||||
operationsPerRun: 100,
|
operationsPerRun: 100,
|
||||||
debugOnly: true,
|
debugOnly: true,
|
||||||
removeStaleWhenUpdated: false,
|
removeIssueStaleWhenUpdated: false,
|
||||||
removeIssueStaleWhenUpdated: undefined,
|
removePrStaleWhenUpdated: false,
|
||||||
removePrStaleWhenUpdated: undefined,
|
|
||||||
ascending: false,
|
ascending: false,
|
||||||
deleteBranch: false,
|
deleteBranch: false,
|
||||||
startDate: '',
|
startDate: '',
|
||||||
|
|
|
@ -598,9 +598,10 @@ test('processing a stale PR will close it when days-before-pr-stale override day
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing a stale issue will close it even if configured not to mark as stale', async () => {
|
test('processing a stale issue will close it even if configured not to mark as stale', async () => {
|
||||||
const opts = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: -1,
|
daysBeforeIssueStale: -1,
|
||||||
|
daysBeforePrStale: -1,
|
||||||
staleIssueMessage: ''
|
staleIssueMessage: ''
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -629,10 +630,10 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing a stale issue will close it even if configured not to mark as stale when days-before-issue-stale override days-before-stale', async () => {
|
test('processing a stale issue will close it even if configured not to mark as stale when days-before-issue-stale override days-before-stale', async () => {
|
||||||
const opts = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 0,
|
|
||||||
daysBeforeIssueStale: -1,
|
daysBeforeIssueStale: -1,
|
||||||
|
daysBeforePrStale: 0,
|
||||||
staleIssueMessage: ''
|
staleIssueMessage: ''
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -661,9 +662,10 @@ test('processing a stale issue will close it even if configured not to mark as s
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing a stale PR will close it even if configured not to mark as stale', async () => {
|
test('processing a stale PR will close it even if configured not to mark as stale', async () => {
|
||||||
const opts = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: -1,
|
daysBeforeIssueStale: -1,
|
||||||
|
daysBeforePrStale: -1,
|
||||||
stalePrMessage: ''
|
stalePrMessage: ''
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -692,9 +694,9 @@ test('processing a stale PR will close it even if configured not to mark as stal
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processing a stale PR will close it even if configured not to mark as stale when days-before-pr-stale override days-before-stale', async () => {
|
test('processing a stale PR will close it even if configured not to mark as stale when days-before-pr-stale override days-before-stale', async () => {
|
||||||
const opts = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: 0,
|
daysBeforeIssueStale: 0,
|
||||||
daysBeforePrStale: -1,
|
daysBeforePrStale: -1,
|
||||||
stalePrMessage: ''
|
stalePrMessage: ''
|
||||||
};
|
};
|
||||||
|
@ -938,7 +940,7 @@ test('stale locked prs will not be closed', async () => {
|
||||||
|
|
||||||
test('exempt issue labels will not be marked stale', async () => {
|
test('exempt issue labels will not be marked stale', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(3);
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Exempt';
|
opts.exemptIssueLabels = 'Exempt';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -967,7 +969,7 @@ test('exempt issue labels will not be marked stale', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exempt issue labels will not be marked stale (multi issue label with spaces)', async () => {
|
test('exempt issue labels will not be marked stale (multi issue label with spaces)', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Exempt, Cool, None';
|
opts.exemptIssueLabels = 'Exempt, Cool, None';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -995,7 +997,7 @@ test('exempt issue labels will not be marked stale (multi issue label with space
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exempt issue labels will not be marked stale (multi issue label)', async () => {
|
test('exempt issue labels will not be marked stale (multi issue label)', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Exempt,Cool,None';
|
opts.exemptIssueLabels = 'Exempt,Cool,None';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1024,7 +1026,7 @@ test('exempt issue labels will not be marked stale (multi issue label)', async (
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exempt pr labels will not be marked stale', async () => {
|
test('exempt pr labels will not be marked stale', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Cool';
|
opts.exemptIssueLabels = 'Cool';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1069,7 +1071,7 @@ test('exempt pr labels will not be marked stale', async () => {
|
||||||
|
|
||||||
test('exempt issue labels will not be marked stale and will remove the existing stale label', async () => {
|
test('exempt issue labels will not be marked stale and will remove the existing stale label', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(3);
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueLabels = 'Exempt';
|
opts.exemptIssueLabels = 'Exempt';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1106,7 +1108,7 @@ test('exempt issue labels will not be marked stale and will remove the existing
|
||||||
});
|
});
|
||||||
|
|
||||||
test('stale issues should not be closed if days is set to -1', async () => {
|
test('stale issues should not be closed if days is set to -1', async () => {
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueClose = -1;
|
opts.daysBeforeIssueClose = -1;
|
||||||
opts.daysBeforePrClose = -1;
|
opts.daysBeforePrClose = -1;
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -1153,7 +1155,11 @@ test('stale issues should not be closed if days is set to -1', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('stale label should be removed if a comment was added to a stale issue', async () => {
|
test('stale label should be removed if a comment was added to a stale issue', async () => {
|
||||||
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
const opts: IIssuesProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
removeIssueStaleWhenUpdated: true,
|
||||||
|
removePrStaleWhenUpdated: true
|
||||||
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
opts,
|
opts,
|
||||||
|
@ -1190,9 +1196,10 @@ test('stale label should be removed if a comment was added to a stale issue', as
|
||||||
|
|
||||||
test('when the option "labelsToAddWhenUnstale" is set, the labels should be added when unstale', async () => {
|
test('when the option "labelsToAddWhenUnstale" is set, the labels should be added when unstale', async () => {
|
||||||
expect.assertions(4);
|
expect.assertions(4);
|
||||||
const opts = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
removeStaleWhenUpdated: true,
|
removeIssueStaleWhenUpdated: true,
|
||||||
|
removePrStaleWhenUpdated: true,
|
||||||
labelsToAddWhenUnstale: 'test'
|
labelsToAddWhenUnstale: 'test'
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -1233,7 +1240,11 @@ test('when the option "labelsToAddWhenUnstale" is set, the labels should be adde
|
||||||
});
|
});
|
||||||
|
|
||||||
test('stale label should not be removed if a comment was added by the bot (and the issue should be closed)', async () => {
|
test('stale label should not be removed if a comment was added by the bot (and the issue should be closed)', async () => {
|
||||||
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
|
const opts: IIssuesProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
removeIssueStaleWhenUpdated: true,
|
||||||
|
removePrStaleWhenUpdated: true
|
||||||
|
};
|
||||||
github.context.actor = 'abot';
|
github.context.actor = 'abot';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1272,7 +1283,8 @@ test('stale label should not be removed if a comment was added by the bot (and t
|
||||||
test('stale label containing a space should be removed if a comment was added to a stale issue', async () => {
|
test('stale label containing a space should be removed if a comment was added to a stale issue', async () => {
|
||||||
const opts: IIssuesProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
removeStaleWhenUpdated: true,
|
removeIssueStaleWhenUpdated: true,
|
||||||
|
removePrStaleWhenUpdated: true,
|
||||||
staleIssueLabel: 'stat: stale'
|
staleIssueLabel: 'stat: stale'
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
|
@ -1302,7 +1314,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: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueStale = 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();
|
||||||
|
@ -1333,7 +1345,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: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueStale = 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();
|
||||||
|
@ -1365,7 +1377,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: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueStale = 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();
|
||||||
|
@ -1396,7 +1408,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: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueStale = 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 = '';
|
||||||
|
@ -1440,7 +1452,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: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueStale = 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';
|
||||||
|
@ -1484,7 +1496,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: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueStale = 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 = '';
|
||||||
|
@ -1528,7 +1540,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: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.daysBeforeIssueStale = 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';
|
||||||
|
@ -1572,7 +1584,10 @@ test('send stale message on prs when stale-pr-message is not empty', async () =>
|
||||||
});
|
});
|
||||||
|
|
||||||
test('git branch is deleted when option is enabled', async () => {
|
test('git branch is deleted when option is enabled', async () => {
|
||||||
const opts = {...DefaultProcessorOptions, deleteBranch: true};
|
const opts: IIssuesProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
deleteBranch: true
|
||||||
|
};
|
||||||
const isPullRequest = true;
|
const isPullRequest = true;
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1601,7 +1616,10 @@ test('git branch is deleted when option is enabled', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('git branch is not deleted when issue is not pull request', async () => {
|
test('git branch is not deleted when issue is not pull request', async () => {
|
||||||
const opts = {...DefaultProcessorOptions, deleteBranch: true};
|
const opts: IIssuesProcessorOptions = {
|
||||||
|
...DefaultProcessorOptions,
|
||||||
|
deleteBranch: true
|
||||||
|
};
|
||||||
const isPullRequest = false;
|
const isPullRequest = false;
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1662,7 +1680,7 @@ test('an issue without a milestone will be marked as stale', async () => {
|
||||||
|
|
||||||
test('an issue without an exempted milestone will be marked as stale', async () => {
|
test('an issue without an exempted milestone will be marked as stale', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(3);
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueMilestones = 'Milestone1';
|
opts.exemptIssueMilestones = 'Milestone1';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1695,7 +1713,7 @@ test('an issue without an exempted milestone will be marked as stale', async ()
|
||||||
|
|
||||||
test('an issue with an exempted milestone will not be marked as stale', async () => {
|
test('an issue with an exempted milestone will not be marked as stale', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(3);
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueMilestones = 'Milestone1';
|
opts.exemptIssueMilestones = 'Milestone1';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1728,7 +1746,7 @@ test('an issue with an exempted milestone will not be marked as stale', async ()
|
||||||
|
|
||||||
test('an issue with an exempted milestone will not be marked as stale (multi milestones with spaces)', async () => {
|
test('an issue with an exempted milestone will not be marked as stale (multi milestones with spaces)', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(3);
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueMilestones = 'Milestone1, Milestone2';
|
opts.exemptIssueMilestones = 'Milestone1, Milestone2';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -1761,7 +1779,7 @@ test('an issue with an exempted milestone will not be marked as stale (multi mil
|
||||||
|
|
||||||
test('an issue with an exempted milestone will not be marked as stale (multi milestones without spaces)', async () => {
|
test('an issue with an exempted milestone will not be marked as stale (multi milestones without spaces)', async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(3);
|
||||||
const opts = {...DefaultProcessorOptions};
|
const opts: IIssuesProcessorOptions = {...DefaultProcessorOptions};
|
||||||
opts.exemptIssueMilestones = 'Milestone1,Milestone2';
|
opts.exemptIssueMilestones = 'Milestone1,Milestone2';
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -2079,7 +2097,8 @@ test('processing an issue stale since less than the daysBeforeStale with a stale
|
||||||
daysBeforeIssueStale: 30,
|
daysBeforeIssueStale: 30,
|
||||||
daysBeforeIssueClose: 7,
|
daysBeforeIssueClose: 7,
|
||||||
closeIssueMessage: 'close message',
|
closeIssueMessage: 'close message',
|
||||||
removeStaleWhenUpdated: false
|
removeIssueStaleWhenUpdated: false,
|
||||||
|
removePrStaleWhenUpdated: false
|
||||||
};
|
};
|
||||||
const now: Date = new Date();
|
const now: Date = new Date();
|
||||||
const updatedAt: Date = new Date(now.setDate(now.getDate() - 9));
|
const updatedAt: Date = new Date(now.setDate(now.getDate() - 9));
|
||||||
|
@ -2120,7 +2139,8 @@ test('processing an issue stale since less than the daysBeforeStale without a st
|
||||||
daysBeforeIssueStale: 30,
|
daysBeforeIssueStale: 30,
|
||||||
daysBeforeIssueClose: 7,
|
daysBeforeIssueClose: 7,
|
||||||
closeIssueMessage: 'close message',
|
closeIssueMessage: 'close message',
|
||||||
removeStaleWhenUpdated: false
|
removeIssueStaleWhenUpdated: false,
|
||||||
|
removePrStaleWhenUpdated: false
|
||||||
};
|
};
|
||||||
const now: Date = new Date();
|
const now: Date = new Date();
|
||||||
const updatedAt: Date = new Date(now.setDate(now.getDate() - 9));
|
const updatedAt: Date = new Date(now.setDate(now.getDate() - 9));
|
||||||
|
|
|
@ -1,555 +1,263 @@
|
||||||
import {Issue} from '../src/classes/issue';
|
import {Issue} from '../src/classes/issue';
|
||||||
import {IIssue} from '../src/interfaces/issue';
|
import {IIssue} from '../src/interfaces/issue';
|
||||||
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
|
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
|
||||||
import {ILabel} from '../src/interfaces/label';
|
import {ILabel} from '../src/interfaces/label';
|
||||||
import {IssuesProcessorMock} from './classes/issues-processor-mock';
|
import {IssuesProcessorMock} from './classes/issues-processor-mock';
|
||||||
import {DefaultProcessorOptions} from './constants/default-processor-options';
|
import {DefaultProcessorOptions} from './constants/default-processor-options';
|
||||||
import {generateIssue} from './functions/generate-issue';
|
import {generateIssue} from './functions/generate-issue';
|
||||||
|
|
||||||
let issuesProcessorBuilder: IssuesProcessorBuilder;
|
let issuesProcessorBuilder: IssuesProcessorBuilder;
|
||||||
let issuesProcessor: IssuesProcessorMock;
|
let issuesProcessor: IssuesProcessorMock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description
|
* @description
|
||||||
* Assuming there is a comment on the issue
|
* Assuming there is a comment on the issue
|
||||||
*/
|
*/
|
||||||
describe('remove-stale-when-updated option', (): void => {
|
describe('remove-issue-stale-when-updated option', (): void => {
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the option "remove-stale-when-updated" is disabled', (): void => {
|
describe('when the option "remove-issue-stale-when-updated" is disabled', (): void => {
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
issuesProcessorBuilder.keepStaleWhenUpdated();
|
issuesProcessorBuilder.keepIssueStaleWhenUpdated();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
await issuesProcessor.processIssues();
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
await issuesProcessor.processIssues();
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the option "remove-stale-when-updated" is enabled', (): void => {
|
describe('when the option "remove-issue-stale-when-updated" is enabled', (): void => {
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
issuesProcessorBuilder.removeStaleWhenUpdated();
|
issuesProcessorBuilder.removeIssueStaleWhenUpdated();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should remove the stale label on the issue', async (): Promise<void> => {
|
test('should remove the stale label on the issue', async (): Promise<void> => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
await issuesProcessor.processIssues();
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
await issuesProcessor.processIssues();
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('remove-issue-stale-when-updated option', (): void => {
|
describe('remove-pr-stale-when-updated option', (): void => {
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the option "remove-stale-when-updated" is disabled', (): void => {
|
describe('when the option "remove-pr-stale-when-updated" is disabled', (): void => {
|
||||||
beforeEach((): void => {
|
beforeEach((): void => {
|
||||||
issuesProcessorBuilder.keepStaleWhenUpdated();
|
issuesProcessorBuilder.keepPrStaleWhenUpdated();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the option "remove-issue-stale-when-updated" is unset', (): void => {
|
test('should remove the stale label on the issue', async (): Promise<void> => {
|
||||||
beforeEach((): void => {
|
expect.assertions(1);
|
||||||
issuesProcessorBuilder.unsetIssueStaleWhenUpdated();
|
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
||||||
});
|
|
||||||
|
await issuesProcessor.processIssues();
|
||||||
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
});
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
||||||
|
expect.assertions(1);
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
||||||
});
|
|
||||||
|
await issuesProcessor.processIssues();
|
||||||
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
});
|
||||||
|
});
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
describe('when the option "remove-pr-stale-when-updated" is enabled', (): void => {
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
beforeEach((): void => {
|
||||||
});
|
issuesProcessorBuilder.removePrStaleWhenUpdated();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the option "remove-issue-stale-when-updated" is disabled', (): void => {
|
test('should remove the stale label on the issue', async (): Promise<void> => {
|
||||||
beforeEach((): void => {
|
expect.assertions(1);
|
||||||
issuesProcessorBuilder.keepIssueStaleWhenUpdated();
|
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
||||||
});
|
|
||||||
|
await issuesProcessor.processIssues();
|
||||||
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
});
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
||||||
|
expect.assertions(1);
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
||||||
});
|
|
||||||
|
await issuesProcessor.processIssues();
|
||||||
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
});
|
||||||
|
});
|
||||||
await issuesProcessor.processIssues();
|
});
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
class IssuesProcessorBuilder {
|
||||||
});
|
private _options: IIssuesProcessorOptions = {
|
||||||
});
|
...DefaultProcessorOptions,
|
||||||
|
removeIssueStaleWhenUpdated: true,
|
||||||
describe('when the option "remove-issue-stale-when-updated" is enabled', (): void => {
|
removePrStaleWhenUpdated: true
|
||||||
beforeEach((): void => {
|
};
|
||||||
issuesProcessorBuilder.removeIssueStaleWhenUpdated();
|
private _issues: Issue[] = [];
|
||||||
});
|
|
||||||
|
keepIssueStaleWhenUpdated(): IssuesProcessorBuilder {
|
||||||
test('should remove the stale label on the issue', async (): Promise<void> => {
|
this._options.removeIssueStaleWhenUpdated = false;
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
return this;
|
||||||
|
}
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
removeIssueStaleWhenUpdated(): IssuesProcessorBuilder {
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
this._options.removeIssueStaleWhenUpdated = true;
|
||||||
});
|
|
||||||
|
return this;
|
||||||
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
}
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
keepPrStaleWhenUpdated(): IssuesProcessorBuilder {
|
||||||
|
this._options.removePrStaleWhenUpdated = false;
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
return this;
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
}
|
||||||
});
|
|
||||||
});
|
removePrStaleWhenUpdated(): IssuesProcessorBuilder {
|
||||||
});
|
this._options.removePrStaleWhenUpdated = true;
|
||||||
|
|
||||||
describe('when the option "remove-stale-when-updated" is enabled', (): void => {
|
return this;
|
||||||
beforeEach((): void => {
|
}
|
||||||
issuesProcessorBuilder.removeStaleWhenUpdated();
|
|
||||||
});
|
issuesOrPrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||||
|
this._issues = issues.map(
|
||||||
describe('when the option "remove-issue-stale-when-updated" is unset', (): void => {
|
(issue: Readonly<Partial<IIssue>>, index: Readonly<number>): Issue =>
|
||||||
beforeEach((): void => {
|
generateIssue(
|
||||||
issuesProcessorBuilder.unsetIssueStaleWhenUpdated();
|
this._options,
|
||||||
});
|
index,
|
||||||
|
issue.title ?? 'dummy-title',
|
||||||
test('should remove the stale label on the issue', async (): Promise<void> => {
|
issue.updated_at ?? new Date().toDateString(),
|
||||||
expect.assertions(1);
|
issue.created_at ?? new Date().toDateString(),
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
!!issue.pull_request,
|
||||||
|
issue.labels ? issue.labels.map(label => label.name) : []
|
||||||
await issuesProcessor.processIssues();
|
)
|
||||||
|
);
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
|
||||||
});
|
return this;
|
||||||
|
}
|
||||||
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
this.issuesOrPrs(
|
||||||
|
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||||
await issuesProcessor.processIssues();
|
return {
|
||||||
|
...issue,
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
pull_request: null
|
||||||
});
|
};
|
||||||
});
|
})
|
||||||
|
);
|
||||||
describe('when the option "remove-issue-stale-when-updated" is disabled', (): void => {
|
|
||||||
beforeEach((): void => {
|
return this;
|
||||||
issuesProcessorBuilder.keepIssueStaleWhenUpdated();
|
}
|
||||||
});
|
|
||||||
|
staleIssues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||||
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
this.issues(
|
||||||
expect.assertions(1);
|
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
return {
|
||||||
|
...issue,
|
||||||
await issuesProcessor.processIssues();
|
updated_at: '2020-01-01T17:00:00Z',
|
||||||
|
created_at: '2020-01-01T17:00:00Z',
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
|
||||||
});
|
return {
|
||||||
|
...label,
|
||||||
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
name: 'Stale'
|
||||||
expect.assertions(1);
|
};
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
}) ?? [
|
||||||
|
{
|
||||||
await issuesProcessor.processIssues();
|
name: 'Stale'
|
||||||
|
}
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
]
|
||||||
});
|
};
|
||||||
});
|
})
|
||||||
|
);
|
||||||
describe('when the option "remove-issue-stale-when-updated" is enabled', (): void => {
|
|
||||||
beforeEach((): void => {
|
return this;
|
||||||
issuesProcessorBuilder.removeIssueStaleWhenUpdated();
|
}
|
||||||
});
|
|
||||||
|
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||||
test('should remove the stale label on the issue', async (): Promise<void> => {
|
this.issuesOrPrs(
|
||||||
expect.assertions(1);
|
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
return {
|
||||||
|
...issue,
|
||||||
await issuesProcessor.processIssues();
|
pull_request: {key: 'value'}
|
||||||
|
};
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
})
|
||||||
});
|
);
|
||||||
|
|
||||||
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
return this;
|
||||||
expect.assertions(1);
|
}
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
|
||||||
|
stalePrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
||||||
await issuesProcessor.processIssues();
|
this.prs(
|
||||||
|
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
return {
|
||||||
});
|
...issue,
|
||||||
});
|
updated_at: '2020-01-01T17:00:00Z',
|
||||||
});
|
created_at: '2020-01-01T17:00:00Z',
|
||||||
});
|
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
|
||||||
|
return {
|
||||||
describe('remove-pr-stale-when-updated option', (): void => {
|
...label,
|
||||||
beforeEach((): void => {
|
name: 'Stale'
|
||||||
issuesProcessorBuilder = new IssuesProcessorBuilder();
|
};
|
||||||
});
|
}) ?? [
|
||||||
|
{
|
||||||
describe('when the option "remove-stale-when-updated" is disabled', (): void => {
|
name: 'Stale'
|
||||||
beforeEach((): void => {
|
}
|
||||||
issuesProcessorBuilder.keepStaleWhenUpdated();
|
]
|
||||||
});
|
};
|
||||||
|
})
|
||||||
describe('when the option "remove-pr-stale-when-updated" is unset', (): void => {
|
);
|
||||||
beforeEach((): void => {
|
|
||||||
issuesProcessorBuilder.unsetPrStaleWhenUpdated();
|
return this;
|
||||||
});
|
}
|
||||||
|
|
||||||
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
build(): IssuesProcessorMock {
|
||||||
expect.assertions(1);
|
return new IssuesProcessorMock(
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
this._options,
|
||||||
|
async p => (p === 1 ? this._issues : []),
|
||||||
await issuesProcessor.processIssues();
|
async () => [
|
||||||
|
{
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
user: {
|
||||||
});
|
login: 'notme',
|
||||||
|
type: 'User'
|
||||||
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
},
|
||||||
expect.assertions(1);
|
body: 'body'
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
}
|
||||||
|
],
|
||||||
await issuesProcessor.processIssues();
|
async () => new Date().toDateString()
|
||||||
|
);
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
}
|
||||||
});
|
}
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the option "remove-pr-stale-when-updated" is disabled', (): void => {
|
|
||||||
beforeEach((): void => {
|
|
||||||
issuesProcessorBuilder.keepPrStaleWhenUpdated();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the option "remove-pr-stale-when-updated" is enabled', (): void => {
|
|
||||||
beforeEach((): void => {
|
|
||||||
issuesProcessorBuilder.removePrStaleWhenUpdated();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not remove the stale label on the issue', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the option "remove-stale-when-updated" is enabled', (): void => {
|
|
||||||
beforeEach((): void => {
|
|
||||||
issuesProcessorBuilder.removeStaleWhenUpdated();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the option "remove-pr-stale-when-updated" is unset', (): void => {
|
|
||||||
beforeEach((): void => {
|
|
||||||
issuesProcessorBuilder.unsetPrStaleWhenUpdated();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should remove the stale label on the issue', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the option "remove-pr-stale-when-updated" is disabled', (): void => {
|
|
||||||
beforeEach((): void => {
|
|
||||||
issuesProcessorBuilder.keepPrStaleWhenUpdated();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should remove the stale label on the issue', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the option "remove-pr-stale-when-updated" is enabled', (): void => {
|
|
||||||
beforeEach((): void => {
|
|
||||||
issuesProcessorBuilder.removePrStaleWhenUpdated();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should remove the stale label on the issue', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should remove the stale label on the pull request', async (): Promise<void> => {
|
|
||||||
expect.assertions(1);
|
|
||||||
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
|
|
||||||
|
|
||||||
await issuesProcessor.processIssues();
|
|
||||||
|
|
||||||
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
class IssuesProcessorBuilder {
|
|
||||||
private _options: IIssuesProcessorOptions = {
|
|
||||||
...DefaultProcessorOptions
|
|
||||||
};
|
|
||||||
private _issues: Issue[] = [];
|
|
||||||
|
|
||||||
keepStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
this._options.removeStaleWhenUpdated = false;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
removeStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
this._options.removeStaleWhenUpdated = true;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsetIssueStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
delete this._options.removeIssueStaleWhenUpdated;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
keepIssueStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
this._options.removeIssueStaleWhenUpdated = false;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
removeIssueStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
this._options.removeIssueStaleWhenUpdated = true;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsetPrStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
delete this._options.removePrStaleWhenUpdated;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
keepPrStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
this._options.removePrStaleWhenUpdated = false;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
removePrStaleWhenUpdated(): IssuesProcessorBuilder {
|
|
||||||
this._options.removePrStaleWhenUpdated = true;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
issuesOrPrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
|
||||||
this._issues = issues.map(
|
|
||||||
(issue: Readonly<Partial<IIssue>>, index: Readonly<number>): Issue =>
|
|
||||||
generateIssue(
|
|
||||||
this._options,
|
|
||||||
index,
|
|
||||||
issue.title ?? 'dummy-title',
|
|
||||||
issue.updated_at ?? new Date().toDateString(),
|
|
||||||
issue.created_at ?? new Date().toDateString(),
|
|
||||||
!!issue.pull_request,
|
|
||||||
issue.labels ? issue.labels.map(label => label.name) : []
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
|
||||||
this.issuesOrPrs(
|
|
||||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
|
||||||
return {
|
|
||||||
...issue,
|
|
||||||
pull_request: null
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
staleIssues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
|
||||||
this.issues(
|
|
||||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
|
||||||
return {
|
|
||||||
...issue,
|
|
||||||
updated_at: '2020-01-01T17:00:00Z',
|
|
||||||
created_at: '2020-01-01T17:00:00Z',
|
|
||||||
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
|
|
||||||
return {
|
|
||||||
...label,
|
|
||||||
name: 'Stale'
|
|
||||||
};
|
|
||||||
}) ?? [
|
|
||||||
{
|
|
||||||
name: 'Stale'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
|
||||||
this.issuesOrPrs(
|
|
||||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
|
||||||
return {
|
|
||||||
...issue,
|
|
||||||
pull_request: {key: 'value'}
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
stalePrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
|
|
||||||
this.prs(
|
|
||||||
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
|
|
||||||
return {
|
|
||||||
...issue,
|
|
||||||
updated_at: '2020-01-01T17:00:00Z',
|
|
||||||
created_at: '2020-01-01T17:00:00Z',
|
|
||||||
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
|
|
||||||
return {
|
|
||||||
...label,
|
|
||||||
name: 'Stale'
|
|
||||||
};
|
|
||||||
}) ?? [
|
|
||||||
{
|
|
||||||
name: 'Stale'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
build(): IssuesProcessorMock {
|
|
||||||
return new IssuesProcessorMock(
|
|
||||||
this._options,
|
|
||||||
async p => (p === 1 ? this._issues : []),
|
|
||||||
async () => [
|
|
||||||
{
|
|
||||||
user: {
|
|
||||||
login: 'notme',
|
|
||||||
type: 'User'
|
|
||||||
},
|
|
||||||
body: 'body'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
async () => new Date().toDateString()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
12
action.yml
12
action.yml
|
@ -92,17 +92,13 @@ inputs:
|
||||||
description: 'The maximum number of operations per run, used to control rate limiting (GitHub API CRUD related).'
|
description: 'The maximum number of operations per run, used to control rate limiting (GitHub API CRUD related).'
|
||||||
default: '30'
|
default: '30'
|
||||||
required: false
|
required: false
|
||||||
remove-stale-when-updated:
|
remove-issue-stale-when-updated:
|
||||||
description: 'Remove stale labels from issues and pull requests when they are updated or commented on.'
|
description: 'Remove stale labels from issues when they are updated or commented on.'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
remove-issue-stale-when-updated:
|
|
||||||
description: 'Remove stale labels from issues when they are updated or commented on. Override "remove-stale-when-updated" option regarding only the issues.'
|
|
||||||
default: ''
|
|
||||||
required: false
|
|
||||||
remove-pr-stale-when-updated:
|
remove-pr-stale-when-updated:
|
||||||
description: 'Remove stale labels from pull requests when they are updated or commented on. Override "remove-stale-when-updated" option regarding only the pull requests.'
|
description: 'Remove stale labels from pull requests when they are updated or commented on.'
|
||||||
default: ''
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
debug-only:
|
debug-only:
|
||||||
description: 'Run the processor in debug mode without actually performing any operations on live issues.'
|
description: 'Run the processor in debug mode without actually performing any operations on live issues.'
|
||||||
|
|
|
@ -297,7 +297,6 @@ const clean_label_1 = __nccwpck_require__(7752);
|
||||||
const get_humanized_date_1 = __nccwpck_require__(965);
|
const get_humanized_date_1 = __nccwpck_require__(965);
|
||||||
const is_date_more_recent_than_1 = __nccwpck_require__(1473);
|
const is_date_more_recent_than_1 = __nccwpck_require__(1473);
|
||||||
const is_valid_date_1 = __nccwpck_require__(891);
|
const is_valid_date_1 = __nccwpck_require__(891);
|
||||||
const is_boolean_1 = __nccwpck_require__(8236);
|
|
||||||
const is_labeled_1 = __nccwpck_require__(6792);
|
const is_labeled_1 = __nccwpck_require__(6792);
|
||||||
const should_mark_when_stale_1 = __nccwpck_require__(2461);
|
const should_mark_when_stale_1 = __nccwpck_require__(2461);
|
||||||
const words_to_list_1 = __nccwpck_require__(1883);
|
const words_to_list_1 = __nccwpck_require__(1883);
|
||||||
|
@ -675,7 +674,7 @@ class IssuesProcessor {
|
||||||
const issueHasUpdate = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose);
|
const issueHasUpdate = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose);
|
||||||
issueLogger.info(`$$type has been updated: ${logger_service_1.LoggerService.cyan(issueHasUpdate)}`);
|
issueLogger.info(`$$type has been updated: ${logger_service_1.LoggerService.cyan(issueHasUpdate)}`);
|
||||||
const shouldRemoveStaleWhenUpdated = this._shouldRemoveStaleWhenUpdated(issue);
|
const shouldRemoveStaleWhenUpdated = this._shouldRemoveStaleWhenUpdated(issue);
|
||||||
issueLogger.info(`The option ${issueLogger.createOptionLink(this._getRemoveStaleWhenUpdatedUsedOptionName(issue))} is: ${logger_service_1.LoggerService.cyan(shouldRemoveStaleWhenUpdated)}`);
|
issueLogger.info(`The option ${issueLogger.createOptionLink(IssuesProcessor._getRemoveStaleWhenUpdatedUsedOptionName(issue))} is: ${logger_service_1.LoggerService.cyan(shouldRemoveStaleWhenUpdated)}`);
|
||||||
if (shouldRemoveStaleWhenUpdated) {
|
if (shouldRemoveStaleWhenUpdated) {
|
||||||
issueLogger.info(`The stale label should not be removed`);
|
issueLogger.info(`The stale label should not be removed`);
|
||||||
}
|
}
|
||||||
|
@ -903,16 +902,9 @@ class IssuesProcessor {
|
||||||
return this.options.anyOfIssueLabels;
|
return this.options.anyOfIssueLabels;
|
||||||
}
|
}
|
||||||
_shouldRemoveStaleWhenUpdated(issue) {
|
_shouldRemoveStaleWhenUpdated(issue) {
|
||||||
if (issue.isPullRequest) {
|
return issue.isPullRequest
|
||||||
if (is_boolean_1.isBoolean(this.options.removePrStaleWhenUpdated)) {
|
? this.options.removePrStaleWhenUpdated
|
||||||
return this.options.removePrStaleWhenUpdated;
|
: this.options.removeIssueStaleWhenUpdated;
|
||||||
}
|
|
||||||
return this.options.removeStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
if (is_boolean_1.isBoolean(this.options.removeIssueStaleWhenUpdated)) {
|
|
||||||
return this.options.removeIssueStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
return this.options.removeStaleWhenUpdated;
|
|
||||||
}
|
}
|
||||||
_removeLabelsWhenUnstale(issue, removeLabels) {
|
_removeLabelsWhenUnstale(issue, removeLabels) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
@ -987,22 +979,15 @@ class IssuesProcessor {
|
||||||
? option_1.Option.DaysBeforePrStale
|
? option_1.Option.DaysBeforePrStale
|
||||||
: option_1.Option.DaysBeforeIssueStale;
|
: option_1.Option.DaysBeforeIssueStale;
|
||||||
}
|
}
|
||||||
|
static _getRemoveStaleWhenUpdatedUsedOptionName(issue) {
|
||||||
|
return issue.isPullRequest
|
||||||
|
? option_1.Option.RemovePrStaleWhenUpdated
|
||||||
|
: option_1.Option.RemoveIssueStaleWhenUpdated;
|
||||||
|
}
|
||||||
_consumeIssueOperation(issue) {
|
_consumeIssueOperation(issue) {
|
||||||
this.operations.consumeOperation();
|
this.operations.consumeOperation();
|
||||||
issue.operations.consumeOperation();
|
issue.operations.consumeOperation();
|
||||||
}
|
}
|
||||||
_getRemoveStaleWhenUpdatedUsedOptionName(issue) {
|
|
||||||
if (issue.isPullRequest) {
|
|
||||||
if (is_boolean_1.isBoolean(this.options.removePrStaleWhenUpdated)) {
|
|
||||||
return option_1.Option.RemovePrStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
return option_1.Option.RemoveStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
if (is_boolean_1.isBoolean(this.options.removeIssueStaleWhenUpdated)) {
|
|
||||||
return option_1.Option.RemoveIssueStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
return option_1.Option.RemoveStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.IssuesProcessor = IssuesProcessor;
|
exports.IssuesProcessor = IssuesProcessor;
|
||||||
|
|
||||||
|
@ -1730,7 +1715,6 @@ var Option;
|
||||||
Option["AnyOfIssueLabels"] = "any-of-issue-labels";
|
Option["AnyOfIssueLabels"] = "any-of-issue-labels";
|
||||||
Option["AnyOfPrLabels"] = "any-of-pr-labels";
|
Option["AnyOfPrLabels"] = "any-of-pr-labels";
|
||||||
Option["OperationsPerRun"] = "operations-per-run";
|
Option["OperationsPerRun"] = "operations-per-run";
|
||||||
Option["RemoveStaleWhenUpdated"] = "remove-stale-when-updated";
|
|
||||||
Option["RemoveIssueStaleWhenUpdated"] = "remove-issue-stale-when-updated";
|
Option["RemoveIssueStaleWhenUpdated"] = "remove-issue-stale-when-updated";
|
||||||
Option["RemovePrStaleWhenUpdated"] = "remove-pr-stale-when-updated";
|
Option["RemovePrStaleWhenUpdated"] = "remove-pr-stale-when-updated";
|
||||||
Option["DebugOnly"] = "debug-only";
|
Option["DebugOnly"] = "debug-only";
|
||||||
|
@ -1849,21 +1833,6 @@ function isValidDate(date) {
|
||||||
exports.isValidDate = isValidDate;
|
exports.isValidDate = isValidDate;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 8236:
|
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.isBoolean = void 0;
|
|
||||||
function isBoolean(value) {
|
|
||||||
return value === true || value === false;
|
|
||||||
}
|
|
||||||
exports.isBoolean = isBoolean;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6792:
|
/***/ 6792:
|
||||||
|
@ -2030,9 +1999,8 @@ function _getAndValidateArgs() {
|
||||||
anyOfIssueLabels: core.getInput('any-of-issue-labels'),
|
anyOfIssueLabels: core.getInput('any-of-issue-labels'),
|
||||||
anyOfPrLabels: core.getInput('any-of-pr-labels'),
|
anyOfPrLabels: core.getInput('any-of-pr-labels'),
|
||||||
operationsPerRun: parseInt(core.getInput('operations-per-run', { required: true })),
|
operationsPerRun: parseInt(core.getInput('operations-per-run', { required: true })),
|
||||||
removeStaleWhenUpdated: !(core.getInput('remove-stale-when-updated') === 'false'),
|
removeIssueStaleWhenUpdated: !(core.getInput('remove-issue-stale-when-updated') === 'false'),
|
||||||
removeIssueStaleWhenUpdated: _toOptionalBoolean('remove-issue-stale-when-updated'),
|
removePrStaleWhenUpdated: !(core.getInput('remove-pr-stale-when-updated') === 'false'),
|
||||||
removePrStaleWhenUpdated: _toOptionalBoolean('remove-pr-stale-when-updated'),
|
|
||||||
debugOnly: core.getInput('debug-only') === 'true',
|
debugOnly: core.getInput('debug-only') === 'true',
|
||||||
ascending: core.getInput('ascending') === 'true',
|
ascending: core.getInput('ascending') === 'true',
|
||||||
deleteBranch: core.getInput('delete-branch') === 'true',
|
deleteBranch: core.getInput('delete-branch') === 'true',
|
||||||
|
@ -2085,27 +2053,6 @@ function processOutput(staledIssues, closedIssues) {
|
||||||
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
|
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @description
|
|
||||||
* From an argument name, get the value as an optional boolean
|
|
||||||
* This is very useful for all the arguments that override others
|
|
||||||
* It will allow us to easily use the original one when the return value is `undefined`
|
|
||||||
* Which is different from `true` or `false` that consider the argument as set
|
|
||||||
*
|
|
||||||
* @param {Readonly<string>} argumentName The name of the argument to check
|
|
||||||
*
|
|
||||||
* @returns {boolean | undefined} The value matching the given argument name
|
|
||||||
*/
|
|
||||||
function _toOptionalBoolean(argumentName) {
|
|
||||||
const argument = core.getInput(argumentName);
|
|
||||||
if (argument === 'true') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (argument === 'false') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
void _run();
|
void _run();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,8 @@ describe('Issue', (): void => {
|
||||||
anyOfIssueLabels: '',
|
anyOfIssueLabels: '',
|
||||||
anyOfPrLabels: '',
|
anyOfPrLabels: '',
|
||||||
operationsPerRun: 0,
|
operationsPerRun: 0,
|
||||||
removeStaleWhenUpdated: false,
|
removeIssueStaleWhenUpdated: false,
|
||||||
removeIssueStaleWhenUpdated: undefined,
|
removePrStaleWhenUpdated: false,
|
||||||
removePrStaleWhenUpdated: undefined,
|
|
||||||
repoToken: '',
|
repoToken: '',
|
||||||
staleIssueMessage: '',
|
staleIssueMessage: '',
|
||||||
stalePrMessage: '',
|
stalePrMessage: '',
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {cleanLabel} from '../functions/clean-label';
|
||||||
import {getHumanizedDate} from '../functions/dates/get-humanized-date';
|
import {getHumanizedDate} from '../functions/dates/get-humanized-date';
|
||||||
import {isDateMoreRecentThan} from '../functions/dates/is-date-more-recent-than';
|
import {isDateMoreRecentThan} from '../functions/dates/is-date-more-recent-than';
|
||||||
import {isValidDate} from '../functions/dates/is-valid-date';
|
import {isValidDate} from '../functions/dates/is-valid-date';
|
||||||
import {isBoolean} from '../functions/is-boolean';
|
|
||||||
import {isLabeled} from '../functions/is-labeled';
|
import {isLabeled} from '../functions/is-labeled';
|
||||||
import {shouldMarkWhenStale} from '../functions/should-mark-when-stale';
|
import {shouldMarkWhenStale} from '../functions/should-mark-when-stale';
|
||||||
import {wordsToList} from '../functions/words-to-list';
|
import {wordsToList} from '../functions/words-to-list';
|
||||||
|
@ -660,7 +659,7 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`The option ${issueLogger.createOptionLink(
|
`The option ${issueLogger.createOptionLink(
|
||||||
this._getRemoveStaleWhenUpdatedUsedOptionName(issue)
|
IssuesProcessor._getRemoveStaleWhenUpdatedUsedOptionName(issue)
|
||||||
)} is: ${LoggerService.cyan(shouldRemoveStaleWhenUpdated)}`
|
)} is: ${LoggerService.cyan(shouldRemoveStaleWhenUpdated)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -974,19 +973,9 @@ export class IssuesProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _shouldRemoveStaleWhenUpdated(issue: Issue): boolean {
|
private _shouldRemoveStaleWhenUpdated(issue: Issue): boolean {
|
||||||
if (issue.isPullRequest) {
|
return issue.isPullRequest
|
||||||
if (isBoolean(this.options.removePrStaleWhenUpdated)) {
|
? this.options.removePrStaleWhenUpdated
|
||||||
return this.options.removePrStaleWhenUpdated;
|
: this.options.removeIssueStaleWhenUpdated;
|
||||||
}
|
|
||||||
|
|
||||||
return this.options.removeStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isBoolean(this.options.removeIssueStaleWhenUpdated)) {
|
|
||||||
return this.options.removeIssueStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.options.removeStaleWhenUpdated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _removeLabelsWhenUnstale(
|
private async _removeLabelsWhenUnstale(
|
||||||
|
@ -1113,29 +1102,16 @@ export class IssuesProcessor {
|
||||||
: Option.DaysBeforeIssueStale;
|
: Option.DaysBeforeIssueStale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static _getRemoveStaleWhenUpdatedUsedOptionName(
|
||||||
|
issue: Readonly<Issue>
|
||||||
|
): Option.RemovePrStaleWhenUpdated | Option.RemoveIssueStaleWhenUpdated {
|
||||||
|
return issue.isPullRequest
|
||||||
|
? Option.RemovePrStaleWhenUpdated
|
||||||
|
: Option.RemoveIssueStaleWhenUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
private _consumeIssueOperation(issue: Readonly<Issue>): void {
|
private _consumeIssueOperation(issue: Readonly<Issue>): void {
|
||||||
this.operations.consumeOperation();
|
this.operations.consumeOperation();
|
||||||
issue.operations.consumeOperation();
|
issue.operations.consumeOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getRemoveStaleWhenUpdatedUsedOptionName(
|
|
||||||
issue: Readonly<Issue>
|
|
||||||
):
|
|
||||||
| Option.RemovePrStaleWhenUpdated
|
|
||||||
| Option.RemoveStaleWhenUpdated
|
|
||||||
| Option.RemoveIssueStaleWhenUpdated {
|
|
||||||
if (issue.isPullRequest) {
|
|
||||||
if (isBoolean(this.options.removePrStaleWhenUpdated)) {
|
|
||||||
return Option.RemovePrStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Option.RemoveStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isBoolean(this.options.removeIssueStaleWhenUpdated)) {
|
|
||||||
return Option.RemoveIssueStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Option.RemoveStaleWhenUpdated;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ export enum Option {
|
||||||
AnyOfIssueLabels = 'any-of-issue-labels',
|
AnyOfIssueLabels = 'any-of-issue-labels',
|
||||||
AnyOfPrLabels = 'any-of-pr-labels',
|
AnyOfPrLabels = 'any-of-pr-labels',
|
||||||
OperationsPerRun = 'operations-per-run',
|
OperationsPerRun = 'operations-per-run',
|
||||||
RemoveStaleWhenUpdated = 'remove-stale-when-updated',
|
|
||||||
RemoveIssueStaleWhenUpdated = 'remove-issue-stale-when-updated',
|
RemoveIssueStaleWhenUpdated = 'remove-issue-stale-when-updated',
|
||||||
RemovePrStaleWhenUpdated = 'remove-pr-stale-when-updated',
|
RemovePrStaleWhenUpdated = 'remove-pr-stale-when-updated',
|
||||||
DebugOnly = 'debug-only',
|
DebugOnly = 'debug-only',
|
||||||
|
|
|
@ -21,9 +21,8 @@ export interface IIssuesProcessorOptions {
|
||||||
anyOfIssueLabels: string;
|
anyOfIssueLabels: string;
|
||||||
anyOfPrLabels: string;
|
anyOfPrLabels: string;
|
||||||
operationsPerRun: number;
|
operationsPerRun: number;
|
||||||
removeStaleWhenUpdated: boolean;
|
removeIssueStaleWhenUpdated: boolean;
|
||||||
removeIssueStaleWhenUpdated: boolean | undefined;
|
removePrStaleWhenUpdated: boolean;
|
||||||
removePrStaleWhenUpdated: boolean | undefined;
|
|
||||||
debugOnly: boolean;
|
debugOnly: boolean;
|
||||||
ascending: boolean;
|
ascending: boolean;
|
||||||
deleteBranch: boolean;
|
deleteBranch: boolean;
|
||||||
|
|
36
src/main.ts
36
src/main.ts
|
@ -53,14 +53,11 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||||
operationsPerRun: parseInt(
|
operationsPerRun: parseInt(
|
||||||
core.getInput('operations-per-run', {required: true})
|
core.getInput('operations-per-run', {required: true})
|
||||||
),
|
),
|
||||||
removeStaleWhenUpdated: !(
|
removeIssueStaleWhenUpdated: !(
|
||||||
core.getInput('remove-stale-when-updated') === 'false'
|
core.getInput('remove-issue-stale-when-updated') === 'false'
|
||||||
),
|
),
|
||||||
removeIssueStaleWhenUpdated: _toOptionalBoolean(
|
removePrStaleWhenUpdated: !(
|
||||||
'remove-issue-stale-when-updated'
|
core.getInput('remove-pr-stale-when-updated') === 'false'
|
||||||
),
|
|
||||||
removePrStaleWhenUpdated: _toOptionalBoolean(
|
|
||||||
'remove-pr-stale-when-updated'
|
|
||||||
),
|
),
|
||||||
debugOnly: core.getInput('debug-only') === 'true',
|
debugOnly: core.getInput('debug-only') === 'true',
|
||||||
ascending: core.getInput('ascending') === 'true',
|
ascending: core.getInput('ascending') === 'true',
|
||||||
|
@ -123,29 +120,4 @@ async function processOutput(
|
||||||
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
|
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description
|
|
||||||
* From an argument name, get the value as an optional boolean
|
|
||||||
* This is very useful for all the arguments that override others
|
|
||||||
* It will allow us to easily use the original one when the return value is `undefined`
|
|
||||||
* Which is different from `true` or `false` that consider the argument as set
|
|
||||||
*
|
|
||||||
* @param {Readonly<string>} argumentName The name of the argument to check
|
|
||||||
*
|
|
||||||
* @returns {boolean | undefined} The value matching the given argument name
|
|
||||||
*/
|
|
||||||
function _toOptionalBoolean(
|
|
||||||
argumentName: Readonly<string>
|
|
||||||
): boolean | undefined {
|
|
||||||
const argument: string = core.getInput(argumentName);
|
|
||||||
|
|
||||||
if (argument === 'true') {
|
|
||||||
return true;
|
|
||||||
} else if (argument === 'false') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _run();
|
void _run();
|
||||||
|
|
Loading…
Reference in New Issue