Edit the drafted merge message before confirming

This commit is contained in:
Ian Gulliver
2026-10-15 18:55:20 -07:00
parent de394b8c35
commit 5a07658523
16 changed files with 324 additions and 211 deletions
+16 -7
View File
@@ -1133,25 +1133,34 @@ export async function confirmMerge(taskId: string): Promise<void> {
void showAlert(errorText(err));
return;
}
await confirmThen(mergeQuestion(task.merge_title, target, coAuthors), "Merge", false, document.querySelector(".merge-button"), async () => {
await post("/api/tasks/{taskId}/merge", { path: { taskId } });
const title = h("input", { type: "text", value: task.merge_title, required: true, maxLength: 72, pattern: ".*\\S.*", class: "modal-field", ariaLabel: "Commit title" });
const question = [h("p", { class: "modal-text" }, `Merge into ${target} as one commit titled:`), title];
const trailers = mergeTrailers(coAuthors);
if (trailers) {
question.push(h("p", { class: "modal-text" }, trailers));
}
await confirmThen(question, "Merge", false, document.querySelector(".merge-button"), async () => {
await post("/api/tasks/{taskId}/merge", { path: { taskId }, body: { merge_title: title.value } });
});
}
function mergeQuestion(title: string, target: string, coAuthors: Participant[]): string {
const lines = [`Merge "${title}" into ${target}?`];
function mergeTrailers(coAuthors: Participant[]): string {
const lines: string[] = [];
const credited = coAuthors.filter((p) => p.git_name && p.git_email);
const missing = coAuthors.filter((p) => !p.git_name || !p.git_email);
if (credited.length > 0) {
lines.push("", "Co-authored-by:", ...credited.map((p) => ` ${p.git_name} <${p.git_email}>`));
lines.push("Co-authored-by:", ...credited.map((p) => ` ${p.git_name} <${p.git_email}>`));
}
if (missing.length > 0) {
lines.push("", "No git identity, so no trailer:", ...missing.map((p) => ` ${p.display_name} (${p.login})`));
if (lines.length > 0) {
lines.push("");
}
lines.push("No git identity, so no trailer:", ...missing.map((p) => ` ${p.display_name} (${p.login})`));
}
return lines.join("\n");
}
async function confirmThen(question: string, action: string, danger: boolean, anchor: Element | null, act: () => Promise<void>) {
async function confirmThen(question: string | Node[], action: string, danger: boolean, anchor: Element | null, act: () => Promise<void>) {
if (!(await showConfirm(question, action, danger, anchor))) {
return;
}