Add Co-authored-by trailers to Merge's squash commit
This commit is contained in:
Vendored
+25
-3
@@ -123,9 +123,19 @@ export function mountTranscript(root) {
|
||||
const target = state.projects.find((p) => p.id === task.project_id)?.default_branch ?? "the default branch";
|
||||
const busy = sess?.state === "running" || sess?.state === "queued";
|
||||
const merge = h("button", { disabled: busy || unmerged?.taskId !== task.id || !unmerged.has, title: `The agent merges ${target} in, then byre squashes into one commit on ${target} and pushes it to origin` }, "Merge");
|
||||
merge.onclick = () => confirmThen(`Merge "${task.title}" into ${target}?`, "Merge", false, async () => {
|
||||
await post("/api/tasks/{taskId}/merge", { path: { taskId: task.id } });
|
||||
});
|
||||
merge.onclick = async () => {
|
||||
let coAuthors;
|
||||
try {
|
||||
coAuthors = await get("/api/tasks/{taskId}/co-authors", { path: { taskId: task.id } });
|
||||
}
|
||||
catch (err) {
|
||||
void showAlert(errorText(err));
|
||||
return;
|
||||
}
|
||||
await confirmThen(mergeQuestion(task.merge_title, target, coAuthors), "Merge", false, async () => {
|
||||
await post("/api/tasks/{taskId}/merge", { path: { taskId: task.id } });
|
||||
});
|
||||
};
|
||||
const mergeIn = h("button", { disabled: busy, title: `Ask the agent to bring ${target} into this branch and resolve any conflicts` }, `Sync from ${target}`);
|
||||
mergeIn.onclick = async () => {
|
||||
mergeIn.disabled = true;
|
||||
@@ -747,6 +757,18 @@ function messageImages(ids) {
|
||||
return h("a", { href: src, target: "_blank", rel: "noopener" }, h("img", { src, alt: "attached image", loading: "lazy" }));
|
||||
}));
|
||||
}
|
||||
function mergeQuestion(title, target, coAuthors) {
|
||||
const lines = [`Merge "${title}" into ${target}?`];
|
||||
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}>`));
|
||||
}
|
||||
if (missing.length > 0) {
|
||||
lines.push("", "No git identity, so no trailer:", ...missing.map((p) => ` ${p.display_name} (${p.login})`));
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
async function confirmThen(question, action, danger, act) {
|
||||
if (!(await showConfirm(question, action, danger))) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user