import React from 'dom-chef'; import select from 'select-dom'; import delegate from 'delegate-it'; import * as pageDetect from 'github-url-detection'; import api from '../github-helpers/api.js'; import features from '../feature-manager.js'; import {getConversationNumber, userCanLikelyMergePR} from '../github-helpers/index.js'; import onCommitTitleUpdate from '../github-events/on-commit-title-update.js'; import observe from '../helpers/selector-observer.js'; import cleanPrCommitTitle from '../helpers/pr-commit-cleaner.js'; const prTitleFieldSelector = 'input#issue_title'; const commitTitleFieldSelector = '.is-squashing form:not([hidden]) input#merge_title_field'; function getCurrentCommitTitleField(): HTMLInputElement | undefined { return select(commitTitleFieldSelector); } function getCurrentCommitTitle(): string | undefined { return getCurrentCommitTitleField()?.value.trim(); } function createCommitTitle(): string { const prTitle = select(prTitleFieldSelector)!.value.trim(); return `${prTitle} (#${getConversationNumber()!})`; } function needsSubmission(): boolean { const currentCommitTitle = getCurrentCommitTitle(); return Boolean(currentCommitTitle) && (createCommitTitle() !== currentCommitTitle); } function getUI(): HTMLElement { const cancelButton = ; return select('.rgh-sync-pr-commit-title-note') ?? (
The title of this PR will be updated to match this title. {cancelButton}
); } function updateUI(): void { if (needsSubmission()) { getCurrentCommitTitleField()!.after(getUI()); } else { getUI().remove(); } } async function updatePRTitle(): Promise