Skip to content

Commit

Permalink
Fixed wrong state mapping with not open and rejected (#4)
Browse files Browse the repository at this point in the history
If a pr is rejected, it now also counts as not open (!open)
This fixes the issue, that rejected prs get constantly reopened.
Additionally drafts are treated correctly as open pull requests.

Co-authored-by: tzerr <[email protected]>
  • Loading branch information
zT-1337 and zT-1337 committed Jan 24, 2024
1 parent cfc6e19 commit afe7f6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/modules/platform/scmm/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ describe('modules/platform/scmm/utils', () => {
[{ ...defaultPr, state: 'MERGED' }, 'all', true],
[{ ...defaultPr, state: 'REJECTED' }, 'all', true],
[{ ...defaultPr, state: 'OPEN' }, 'open', true],
[{ ...defaultPr, state: 'DRAFT' }, 'open', false],
[{ ...defaultPr, state: 'DRAFT' }, 'open', true],
[{ ...defaultPr, state: 'MERGED' }, 'open', false],
[{ ...defaultPr, state: 'REJECTED' }, 'open', false],
[{ ...defaultPr, state: 'OPEN' }, '!open', false],
[{ ...defaultPr, state: 'DRAFT' }, '!open', false],
[{ ...defaultPr, state: 'MERGED' }, '!open', true],
[{ ...defaultPr, state: 'REJECTED' }, '!open', false],
[{ ...defaultPr, state: 'REJECTED' }, '!open', true],
[{ ...defaultPr, state: 'OPEN' }, 'closed', false],
[{ ...defaultPr, state: 'DRAFT' }, 'closed', false],
[{ ...defaultPr, state: 'MERGED' }, 'closed', true],
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/scmm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export function matchPrState(pr: Pr, state: PrFilterByState): boolean {
return true;
}

if (state === 'open' && pr.state === 'OPEN') {
if (state === 'open' && (pr.state === 'OPEN' || pr.state === 'DRAFT')) {
return true;
}

if (state === '!open' && pr.state === 'MERGED') {
if (state === '!open' && (pr.state === 'MERGED' || pr.state === 'REJECTED')) {
return true;
}

Expand Down

0 comments on commit afe7f6b

Please sign in to comment.