MCPcopy Index your code
hub / github.com/refined-github/refined-github / useCommitTitle

Function useCommitTitle

source/features/pr-first-commit-title.tsx:21–51  ·  view source on GitHub ↗
(firstCommitTitle: HTMLElement)

Source from the content-addressed store, hash-verified

19}
20
21function 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
53function init(signal: AbortSignal): void {
54 observe('#commits_bucket > :first-child .js-commits-list-item:first-child p', useCommitTitle, {signal});

Callers

nothing calls this directly

Calls 2

looseParseIntFunction · 0.85
getFirstCommitFunction · 0.85

Tested by

no test coverage detected