Skip to content

Commit 9461cb1

Browse files
fix: only-issue-types does not affect PRs (#1338)
* fix: does not affect PRs * docs: mention new behaviour specifically in README.md * test: add new test case to avoid regression * chore: run build
1 parent eb5cf3a commit 9461cb1

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ A comma separated list of allowed issue types. Only issues with a matching type
569569

570570
If unset (or an empty string), this option will not alter the stale workflow.
571571

572+
This option does not affect PRs.
573+
572574
Default value: unset
573575

574576
### Usage

‎__tests__/only-issue-types.spec.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,37 @@ describe('only-issue-types option', () => {
122122
'A feature'
123123
]);
124124
});
125+
126+
test('should ignore onlyIssueTypes filter when item is a pull request', async () => {
127+
const opts: IIssuesProcessorOptions = {
128+
...DefaultProcessorOptions,
129+
onlyIssueTypes: 'bug'
130+
};
131+
const TestIssueList: Issue[] = [
132+
generateIssue(
133+
opts,
134+
1,
135+
'A pull request',
136+
'2020-01-01T17:00:00Z',
137+
'2020-01-01T17:00:00Z',
138+
false,
139+
true, // isPullRequest = true
140+
[],
141+
false,
142+
false,
143+
undefined,
144+
[],
145+
undefined // pull requests do not have an issue_type
146+
)
147+
];
148+
const processor = new IssuesProcessorMock(
149+
opts,
150+
alwaysFalseStateMock,
151+
async p => (p === 1 ? TestIssueList : []),
152+
async () => [],
153+
async () => new Date().toDateString()
154+
);
155+
await processor.processIssues(1);
156+
expect(processor.staleIssues.map(i => i.title)).toEqual(['A pull request']);
157+
});
125158
});

‎dist/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class IssuesProcessor {
513513
IssuesProcessor._endIssueProcessing(issue);
514514
return; // If the issue has an 'include-only-assigned' option set, process only issues with nonempty assignees list
515515
}
516-
if (this.options.onlyIssueTypes) {
516+
if (this.options.onlyIssueTypes && !issue.isPullRequest) {
517517
const allowedTypes = this.options.onlyIssueTypes
518518
.split(',')
519519
.map(t => t.trim().toLowerCase())

‎src/classes/issues-processor.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class IssuesProcessor {
252252
return; // If the issue has an 'include-only-assigned' option set, process only issues with nonempty assignees list
253253
}
254254

255-
if (this.options.onlyIssueTypes) {
255+
if (this.options.onlyIssueTypes && !issue.isPullRequest) {
256256
const allowedTypes = this.options.onlyIssueTypes
257257
.split(',')
258258
.map(t => t.trim().toLowerCase())

0 commit comments

Comments
 (0)