Merge branch 'fix/hub-cleanup-pkgmgr-local' into unify/skills-20261114
This commit is contained in:
commit
568747651b
19 files changed
+1534
-189
No files matched your search
@@ -1,6 +1,6 @@
|
||||
const CLEANUP_POLL = 2000;
|
||||
const CLEANUP_PATIENCE = 900000;
|
||||
const RESULT_LABELS = {done: ["deleted", "ok"], refused: ["refused", "bad"], failed: ["failed", "bad"]};
|
||||
const RESULT_LABELS = {done: ["deleted", "ok"], gone: ["gone", "warn"], refused: ["refused", "bad"], failed: ["failed", "bad"]};
|
||||
|
||||
function planOf(item) {
|
||||
const repo = (tree.data.repos || []).find((entry) => entry.path === item.repository);
|
||||
@@ -8,16 +8,18 @@
|
||||
return {repo, entry};
|
||||
}
|
||||
|
||||
function deleteDialog(items, locked = [], held = []) {
|
||||
function deleteDialog(items, locked = [], held = [], kept = []) {
|
||||
if (!items.length) {
|
||||
return;
|
||||
}
|
||||
const rows = [...items, ...locked, ...held].map((item) => {
|
||||
const rows = [...items, ...locked, ...held, ...kept].map((item) => {
|
||||
const {repo, entry} = planOf(item);
|
||||
const waits = locked.includes(item);
|
||||
const kept = held.includes(item);
|
||||
return h("li", {class: waits ? "dry-run locked" : kept ? "dry-run held" : "dry-run", "data-token": waits ? "needed" : null, "data-held": kept && entry ? entry.held : null},
|
||||
h("div", {class: "row"}, h("strong", {}, revealed(repo ? repo.name : item.repository)), h("code", {}, revealed(item.branch)), waits ? chip("bi-key", "token needed", "warn") : kept ? chip("bi-folder-symlink", "held by a worktree: not deleted here", "neutral") : null),
|
||||
const holds = held.includes(item);
|
||||
const keeps = kept.includes(item);
|
||||
return h("li", {class: waits ? "dry-run locked" : holds ? "dry-run held" : keeps ? "dry-run kept" : "dry-run", "data-token": waits ? "needed" : null, "data-held": holds && entry ? entry.held : null, "data-kept": keeps && entry ? entry.kept : null},
|
||||
h("div", {class: "row"}, h("strong", {}, revealed(repo ? repo.name : item.repository)), h("code", {}, revealed(item.branch)),
|
||||
waits ? chip("bi-key", "token needed", "warn") : holds ? chip("bi-folder-symlink", "held by a worktree: not deleted here", "neutral") : keeps ? chip("bi-sign-merge-left", "kept by the --local dry run: not deleted here", "neutral") : null),
|
||||
h("pre", {}, (entry ? entry.plan : [`${item.branch} @ ${item.tip.slice(0, 12)}`]).map(revealed).join("\n")));
|
||||
});
|
||||
const outcome = h("div", {class: "mini", "aria-live": "polite"});
|
||||
@@ -29,7 +31,7 @@
|
||||
}
|
||||
});
|
||||
openSheet(items.length > 1 ? `Delete ${items.length} merged branches` : `Delete ${items[0].branch}`, [
|
||||
h("p", {class: "muted"}, "Dry run of pkgmgr branch cleanup for exactly these entries: it deletes the local branch and never touches a worktree, Compose stack or volume. No remote branch: the host refuses an entry whose plan deletes one. A branch held by a worktree is not deleted here: branch gc (kvb-git-gc, pkgmgr gc) removes it, and its docker compose down -v deletes the stack's volumes. The host checks your signature and refuses every entry whose state has changed since."),
|
||||
h("p", {class: "muted"}, "Dry run of pkgmgr branch cleanup for exactly these entries: it deletes the local branch and never touches a worktree, Compose stack or volume. No remote branch: the host refuses an entry whose plan deletes one. A branch held by a worktree is not deleted here: branch gc (kvb-git-gc, pkgmgr gc) removes it, and its docker compose down -v deletes the stack's volumes. Neither is a branch the pkgmgr branch cleanup --local dry run keeps, such as one merged by pull request, squash or patch whose local tip is no ancestor of the default branch: branch gc removes it. The host checks your signature and refuses every entry whose state has changed since."),
|
||||
h("ul", {class: "mini", "aria-label": "Dry run"}, rows),
|
||||
outcome,
|
||||
h("div", {class: "actions"}, h("span", {class: "spacer"}), btn("Cancel", "btn ghost", closeSheet), confirm),
|
||||
|
||||
@@ -27,12 +27,15 @@
|
||||
|
||||
const FORGE_UNAVAILABLE = "forge unavailable";
|
||||
const deletableNow = (entry) => Boolean(entry.cleanup) && (tree.data.delete_ready === true || entry.token_free === true);
|
||||
const tokenLocked = (entry) => tree.data.delete_ready !== true && entry.state === "merged-clean" && !entry.held && (entry.cleanup ? entry.token_free !== true : entry.skip === FORGE_UNAVAILABLE);
|
||||
const tokenLocked = (entry) => tree.data.delete_ready !== true && entry.state === "merged-clean" && !entry.held && !entry.kept && (entry.cleanup ? entry.token_free !== true : entry.skip === FORGE_UNAVAILABLE);
|
||||
|
||||
function deleteButton(entry) {
|
||||
if (entry.held) {
|
||||
return h("span", {class: "hint held", title: entry.held}, chip("bi-folder-symlink", entry.held, "neutral"));
|
||||
}
|
||||
if (entry.kept) {
|
||||
return h("span", {class: "hint kept", title: entry.kept}, chip("bi-sign-merge-left", entry.kept, "neutral"));
|
||||
}
|
||||
if (!entry.cleanup) {
|
||||
return tokenLocked(entry) ? chip("bi-key", "token needed", "warn") : null;
|
||||
}
|
||||
@@ -53,14 +56,17 @@
|
||||
const items = branches.filter(deletableNow).map((entry) => entry.cleanup);
|
||||
const waiting = branches.filter(tokenLocked);
|
||||
const locked = waiting.filter((entry) => entry.cleanup).map((entry) => entry.cleanup);
|
||||
const held = (tree.data.repos || []).flatMap((repo) => repo.branches.filter((entry) => entry.held).map((entry) => ({repository: repo.path, branch: entry.name, tip: entry.head})));
|
||||
const preview = (key) => (tree.data.repos || []).flatMap((repo) => repo.branches.filter((entry) => entry[key]).map((entry) => ({repository: repo.path, branch: entry.name, tip: entry.head})));
|
||||
const held = preview("held");
|
||||
const kept = preview("kept");
|
||||
const ready = items.length > 0;
|
||||
const hint = !ready && tree.data.delete_ready !== true ? `Delete all merged blocked: ${tree.data.delete_reason || "delete_ready is false"}` : items.length ? `Delete all merged: ${items.length} branches after dry run and signature` : "Delete all merged: no merged branch without a skip reason";
|
||||
const button = iconBtn("bi-trash3-fill", "Delete all merged", "btn small danger", () => deleteDialog(items, locked, held), hint);
|
||||
const button = iconBtn("bi-trash3-fill", "Delete all merged", "btn small danger", () => deleteDialog(items, locked, held, kept), hint);
|
||||
button.disabled = !ready;
|
||||
return h("span", {class: "hint", title: hint}, button, items.length ? counter(items.length) : null,
|
||||
waiting.length ? chip("bi-key", `${waiting.length} token needed`, "warn", waiting.length) : null,
|
||||
held.length ? chip("bi-folder-symlink", `${held.length} held by a worktree: use branch gc`, "neutral", held.length) : null,
|
||||
kept.length ? chip("bi-sign-merge-left", `${kept.length} kept by the --local dry run: see each dry run`, "neutral", kept.length) : null,
|
||||
tree.data.delete_ready !== true ? iconBtn("bi-key-fill", "Store token", "btn small soft", storeToken, "Store token: add the operator row that stores the GitHub token in the Secret Service") : null);
|
||||
}
|
||||
|
||||
@@ -92,8 +98,10 @@
|
||||
return found.length ? found[found.length - 1] : null;
|
||||
}
|
||||
|
||||
const RESULT_CHIPS = {done: ["bi-check2-all", "deleted", "ok"], gone: ["bi-question-octagon", "gone", "warn"], refused: ["bi-x-octagon", "refused", "bad"], failed: ["bi-exclamation-triangle", "failed", "bad"]};
|
||||
|
||||
function resultChip(result) {
|
||||
const [name, label, tone] = result.status === "done" ? ["bi-check2-all", "deleted", "ok"] : result.status === "refused" ? ["bi-x-octagon", "refused", "bad"] : ["bi-exclamation-triangle", "failed", "bad"];
|
||||
const [name, label, tone] = RESULT_CHIPS[result.status] || RESULT_CHIPS.failed;
|
||||
return chip(name, `${label}${result.reason ? `: ${result.reason}` : ""}`, tone);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user