(signal: AbortSignal)
| 30 | ]; |
| 31 | |
| 32 | async function init(signal: AbortSignal): Promise<void> { |
| 33 | // Skip branches that are likely to be long-lived https://github.com/refined-github/refined-github/issues/7755 |
| 34 | const {head} = getBranches(); |
| 35 | if (matchesAnyPattern(head.branch, exceptions)) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | // Skip branches that have PRs open https://github.com/refined-github/refined-github/issues/7782 |
| 40 | const {repository} = await api.v4(GetPrsToBaseBranchAndDeleteOnMerge, { |
| 41 | variables: { |
| 42 | baseRefName: head.branch, |
| 43 | }, |
| 44 | }); |
| 45 | if (repository.pullRequests.totalCount > 0 || repository.deleteBranchOnMerge) { |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | await waitForPrMerge(signal); |
| 50 | |
| 51 | const branchDeletionButton = await elementReady('div[class^="MergeBoxSectionHeader-module__contentLayout"] button', { |
| 52 | predicate: button => button.textContent.trim() === 'Delete branch', |
| 53 | stopOnDomReady: false, |
| 54 | signal, |
| 55 | }); |
| 56 | branchDeletionButton!.click(); |
| 57 | |
| 58 | const deletionEvent = await elementReady('.TimelineItem-body:has(.pull-request-ref-restore-text)', { |
| 59 | stopOnDomReady: false, |
| 60 | signal, |
| 61 | }); |
| 62 | const url |
| 63 | = 'https://github.com/refined-github/refined-github/wiki/Extended-feature-descriptions#pr-branch-auto-delete'; |
| 64 | deletionEvent!.append( |
| 65 | <a className="d-inline-block" href={url}> |
| 66 | via Refined GitHub <InfoIcon /> |
| 67 | </a>, |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | void features.add(import.meta.url, { |
| 72 | asLongAs: [ |
nothing calls this directly
no test coverage detected