Skip to content

Commit 50de384

Browse files
committed
Improve isMergedPR and isClosedPR
1 parent 79147db commit 50de384

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,19 @@ TEST: addTests('isQuickPR', [
288288

289289
export const isDraftPR = (): boolean => exists('#partial-discussion-header .octicon-git-pull-request-draft');
290290
export const isOpenPR = (): boolean => exists('#partial-discussion-header :is(.octicon-git-pull-request, .octicon-git-pull-request-draft)');
291-
export const isMergedPR = (): boolean => exists('#partial-discussion-header .octicon-git-merge');
292-
export const isClosedPR = (): boolean => exists('#partial-discussion-header :is(.octicon-git-pull-request-closed, .octicon-git-merge)');
291+
export const isMergedPR = (): boolean => {
292+
if (exists('#partial-discussion-header :is(.octicon-git-merge)'))
293+
return true;
294+
const status = $('[class^="StateLabel"]')!.textContent
295+
return status === 'Merged'
296+
}
297+
export const isClosedPR = (): boolean => {
298+
if (exists('#partial-discussion-header :is(.octicon-git-pull-request-closed, .octicon-git-merge)'))
299+
return true;
300+
const status = $('[class^="StateLabel"]')!.textContent
301+
return status === 'Closed' || status === 'Merged'
302+
}
303+
293304
export const isClosedIssue = (): boolean => exists('#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)');
294305

295306
export const isReleases = (url: URL | HTMLAnchorElement | Location = location): boolean => getRepo(url)?.path === 'releases';

0 commit comments

Comments
 (0)