(firstCommitTitle: HTMLElement)
| 19 | } |
| 20 | |
| 21 | function useCommitTitle(firstCommitTitle: HTMLElement): void { |
| 22 | const requestedContent = new URL(location.href).searchParams; |
| 23 | const commitCount = $([ |
| 24 | // Few commits |
| 25 | 'div.Box:is(.tmp-mb-3, .mb-3) .octicon-git-commit + span', |
| 26 | // Many commits (rendered in tabs) |
| 27 | 'a[href="#commits_bucket"] .Counter', |
| 28 | ]); |
| 29 | if (looseParseInt(commitCount) < 2 || !elementExists('#new_pull_request')) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | const firstCommit = getFirstCommit(firstCommitTitle); |
| 34 | |
| 35 | if (!requestedContent.has('pull_request[title]')) { |
| 36 | setFieldText( |
| 37 | $([ |
| 38 | 'input[name="pull_request[title]"]', |
| 39 | '#pull_request_title', // Remove after August 2026 |
| 40 | ]), |
| 41 | firstCommit.title, |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | if (firstCommit.body && !requestedContent.has('pull_request[body]')) { |
| 46 | insertTextIntoField( |
| 47 | $('#pull_request_body'), |
| 48 | firstCommit.body, |
| 49 | ); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | function init(signal: AbortSignal): void { |
| 54 | observe('#commits_bucket > :first-child .js-commits-list-item:first-child p', useCommitTitle, {signal}); |
nothing calls this directly
no test coverage detected