Порівняти коміти

..
Автор SHA1 Повідомлення Дата
l0ng-ai f25740f14d fix(vcs): handle repositories nested below a non-Git project root
- Project view: the Git submenu was gated on the project root being a
  repository, so it never appeared when the repositories are found later
  below a non-Git root. It now also follows the VCS availability that the
  Commit tool window uses.
- Commit: when only one repository had included changes, every staged but
  excluded file of every repository was passed to it, and the commit failed
  with "<path> is outside the repository". Paths that belong to another known
  repository are now left to that repository.

Fixes #2517
Fixes #2518
2026-11-10 23:07:22 +08:00
22 змінених файлів з 32 додано та 300 видалено

No files matched your search

Створено
+2 -3
Переглянути файл
@@ -12152,15 +12152,14 @@ dependencies = [
[[package]]
name = "zip"
version = "9.2.3"
version = "9.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00fb4744e923442ecadfd3f85f51a5d24e03bf43d53813b81ebb4c91d02baa62"
checksum = "1156b39d142a34b999c2310a50455e0cb3760bf7efad0122f796d813bee26ccb"
dependencies = [
"crc32fast",
"flate2",
"getrandom 0.4.3",
"indexmap 2.14.2",
"libc",
"memchr",
"nix 0.31.3",
"typed-path",
+1 -1
Переглянути файл
@@ -82,7 +82,7 @@ trash = "5"
blake3 = "1"
dunce = "1"
dirs = "6"
zip = { version = "9.2.3", default-features = false, features = ["deflate"] }
zip = { version = "9", default-features = false, features = ["deflate"] }
# search, index, language
grep-searcher = "0.1"
-42
Переглянути файл
@@ -1228,48 +1228,6 @@ mod tests {
}
zip.finish().unwrap();
}
#[test]
fn explodes_wars_with_multibyte_path_components() {
let tmp = tempfile::tempdir().unwrap();
let war = tmp.path().join("app.war");
let entries = [
("bdms300-front/dist/img/ZC机柜.jpg", "reported case"),
("img/A机柜.jpg", "one ASCII byte"),
("img/😀.jpg", "four-byte character"),
("img/abé.jpg", "two-byte character"),
("ZC机柜/index.jsp", "multibyte directory"),
("img/普通.jpg", "character boundary"),
];
archive(&war, &entries);
for resources_only in [false, true] {
let destination = tmp.path().join(format!("out-{resources_only}"));
explode(&war, &destination, resources_only).unwrap();
for (name, text) in entries {
assert_eq!(fs::read_to_string(destination.join(name)).unwrap(), text, "{name}");
}
}
}
#[test]
fn rejects_war_path_traversal() {
let tmp = tempfile::tempdir().unwrap();
let war = tmp.path().join("app.war");
archive(&war, &[("../escape.txt", "outside")]);
assert!(explode(&war, &tmp.path().join("out"), false).is_err());
assert!(!tmp.path().join("escape.txt").exists());
}
#[cfg(windows)]
#[test]
fn rejects_war_reserved_device_paths() {
let tmp = tempfile::tempdir().unwrap();
let war = tmp.path().join("app.war");
for name in ["CON.txt", "NUL", "COM1.txt", "LPT¹", "img/aux.jpg"] {
archive(&war, &[(name, "device")]);
assert!(explode(&war, &tmp.path().join("out"), false).is_err(), "{name}");
}
}
#[test]
fn keeps_the_apps_own_context_descriptor() {
let tmp = tempfile::tempdir().unwrap();
+2 -9
Переглянути файл
@@ -99,15 +99,8 @@ fn config(line: &str) -> RunConfig {
}
fn holder_port(dir: &std::path::Path) -> u16 {
// The file appears as soon as the holder creates it, before the port is written and
// the handle closed: on a loaded machine (defender, indexer) the first reads can hit
// a sharing violation or a partial write, so keep reading until it parses.
let mut port = None;
wait_for("the holder's port", || {
port = std::fs::read_to_string(dir.join("port")).ok().and_then(|s| s.trim().parse().ok());
port.is_some()
});
port.unwrap()
wait_for("the holder's port", || std::fs::metadata(dir.join("port")).is_ok());
std::fs::read_to_string(dir.join("port")).unwrap().trim().parse().unwrap()
}
#[test]
-18
Переглянути файл
@@ -443,24 +443,6 @@ mod tests {
}
}
#[test]
fn extracts_zip_with_multibyte_path_components() {
let tmp = tempfile::tempdir().unwrap();
let archive = tmp.path().join("tool.zip");
let entries: &[(&str, &[u8], u32)] = &[
("bdms300-front/dist/img/ZC机柜.jpg", b"reported case", 0o644),
("A机柜/file", b"directory", 0o644),
("abé.txt", b"two-byte character", 0o644),
("😀.txt", b"four-byte character", 0o644),
];
zip_file(&archive, entries);
let dest = tmp.path().join("out");
extract(&archive, ArchiveKind::Zip, &dest, "x", &CancellationToken::new()).unwrap();
for (name, data, _) in entries {
assert_eq!(fs::read(dest.join(name)).unwrap(), *data, "{name}");
}
}
#[test]
fn extracts_zip_with_modes_and_nested_dirs() {
let tmp = tempfile::tempdir().unwrap();
-12
Переглянути файл
@@ -1,12 +0,0 @@
import "../src/styles/global.css";
import { createRoot } from "react-dom/client";
import { usePlatform } from "../src/platform/platformInfo";
import { Dialog } from "../src/ui/Dialog";
usePlatform.setState({ os: "macos", overlayTitleBar: true });
document.body.innerHTML = `<div id="root"></div>`;
createRoot(document.querySelector("#root")!).render(
<Dialog open title="Push Commits to origin/main" onClose={() => {}} width={860} maxHeight={720} resizable="both">
<div style={{ height: 2000 }} />
</Dialog>,
);
-10
Переглянути файл
@@ -1,10 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Dialog title bar fixture</title>
</head>
<body>
<script type="module" src="./dialogTitleBar.fixture.tsx"></script>
</body>
</html>
-28
Переглянути файл
@@ -1,28 +0,0 @@
import { test, expect, type Page } from "@playwright/test";
async function titleBarHeight(page: Page) {
return page.evaluate(() => parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--h-titlebar")));
}
// Reduced motion skips the opening animation, which scales the dialog while it runs.
test.use({ viewport: { width: 1200, height: 640 }, reducedMotion: "reduce" });
test("a dialog taller than the window stays below the macOS window buttons", async ({ page }) => {
await page.goto("/e2e/dialogTitleBar.html");
const dialog = page.getByRole("dialog");
await expect(dialog).toBeVisible();
const box = (await dialog.boundingBox())!;
expect(box.y).toBeGreaterThanOrEqual(await titleBarHeight(page));
});
test("dragging a dialog up stops below the macOS window buttons", async ({ page }) => {
await page.goto("/e2e/dialogTitleBar.html");
const title = page.getByRole("dialog").locator("[data-dialog-titlebar] span").last();
const start = (await title.boundingBox())!;
await page.mouse.move(start.x + 40, start.y + start.height / 2);
await page.mouse.down();
await page.mouse.move(start.x + 40, 0, { steps: 8 });
await page.mouse.up();
const box = (await page.getByRole("dialog").boundingBox())!;
expect(box.y).toBeGreaterThanOrEqual(await titleBarHeight(page));
});
-10
Переглянути файл
@@ -72,16 +72,6 @@ test("plugin markers render names and package SVG variants and keep the indexed
await expect(markers.locator('[title="Database marker"] svg')).toHaveAttribute("data-icon", "database");
const custom = markers.locator('[title="Package marker"] svg');
await expect(custom).toHaveAttribute("data-icon", /^ext:pluginIcon\/hello\//);
// CodeMirror clips every gutter column to its width (`overflow: hidden`), so an icon wider than
// the column loses its edges: each line-marker icon stays inside the 14px column.
const outside = await markers.evaluate((column) => {
const bounds = column.getBoundingClientRect();
return [...column.querySelectorAll("svg")].filter((svg) => {
const box = svg.getBoundingClientRect();
return box.left < bounds.left - 0.5 || box.right > bounds.right + 0.5;
}).length;
});
expect(outside).toBe(0);
await page.evaluate(async () => {
const path = "/src/workbench/theme.ts";
await (await import(path)).setTheme("dark");
+3 -17
Переглянути файл
@@ -31,13 +31,7 @@
const message = String(reason);
return reason.stack.includes(message) ? reason.stack : `${message}\n${reason.stack}`;
}
if (typeof reason === "string") return reason;
// WebKit's fetch / network TypeErrors carry no stack and serialise to "{}".
if (reason instanceof Error || typeof reason?.message === "string") {
const name = typeof reason.name === "string" ? reason.name : "Error";
return `${name}: ${reason.message}`;
}
return JSON.stringify(reason) || String(reason);
return (typeof reason === "string" ? reason : JSON.stringify(reason)) || String(reason);
} catch {
return "Unknown startup error";
}
@@ -108,12 +102,7 @@
show(event.error || `${event.message}\n${event.filename || ""}:${event.lineno || 0}:${event.colno || 0}`);
}
};
// An unhandled rejection doesn't stop startup by itself (a failed background request
// rejects too); keep the first one for the timeout report instead of failing on it.
let rejection;
const onRejection = (event) => {
if (rejection === undefined) rejection = describe(event.reason);
};
const onRejection = (event) => show(event.reason);
const onBootError = (event) => show(event.detail);
const onReady = () => {
ready = true;
@@ -123,10 +112,7 @@
window.removeEventListener("openidea:boot-error", onBootError);
window.removeEventListener("openidea:boot-ready", onReady);
};
const timer = window.setTimeout(
() => show(rejection === undefined ? text.timeout : `${text.timeout}\n\nUnhandled rejection: ${rejection}`),
30_000,
);
const timer = window.setTimeout(() => show(text.timeout), 30_000);
window.addEventListener("error", onError, true);
window.addEventListener("unhandledrejection", onRejection);
window.addEventListener("openidea:boot-error", onBootError);
-5
Переглянути файл
@@ -134,11 +134,6 @@ describe("debug tool window", () => {
expect(console.getAttribute("aria-selected")).toBe("true");
act(() => useDebug.setState({ sessions: { 1: session } }));
expect(variables.getAttribute("aria-selected")).toBe("true");
// Stepping from the Console keeps it in front.
fireEvent.click(console);
act(() => useDebug.setState({ sessions: { 1: { ...session, status: "running" } } }));
act(() => useDebug.setState({ sessions: { 1: { ...session, stopReason: "step" } } }));
expect(console.getAttribute("aria-selected")).toBe("true");
});
it("renders session tabs, views, frames and typed variables", async () => {
+1 -8
Переглянути файл
@@ -153,14 +153,7 @@ export function DebugToolWindow() {
setView({
session: active.startedAt,
status: active.status,
// A breakpoint or exception brings Threads & Variables to the front; finishing a step keeps
// the tab the user is on (e.g. Console, to watch the output while stepping).
tab:
active.status === "starting"
? "console"
: active.status === "paused" && active.stopReason !== "step"
? "variables"
: view.tab,
tab: active.status === "starting" ? "console" : active.status === "paused" ? "variables" : view.tab,
});
const tab = view.tab;
+1 -4
Переглянути файл
@@ -97,10 +97,7 @@ export function indexedMarkers(path: string): Extension {
display: "flex",
alignItems: "center",
},
// Only the indexed-marker column sizes its icons to 16px. Line markers reuse the button class
// in their own 14px column (lineMarkerGutter.ts, LineMarkers.module.css), whose `overflow: hidden`
// would clip an icon this size at its edges.
".cm-plugin-mapping-gutter .cm-plugin-mapping-button svg": { width: "16px", height: "16px" },
".cm-plugin-mapping-button svg": { width: "16px", height: "16px" },
".cm-plugin-mapping-button:focus-visible": { outline: "1px solid var(--accent)" },
}),
ViewPlugin.fromClass(
+3 -5
Переглянути файл
@@ -339,15 +339,13 @@ export function nodeMenu(
},
]
: []),
// Both destinations, as in the project view's Git menu.
...(toIgnore.length
? [
{
kind: "action" as const,
action: "vcs.ignoreShared",
arg: toIgnore,
label: "Add to .gitignore",
submenu: [
{ kind: "action" as const, action: "vcs.ignoreShared", arg: toIgnore, label: ".gitignore" },
{ kind: "action" as const, action: "vcs.ignoreLocal", arg: toIgnore, label: ".git/info/exclude" },
],
},
]
: []),
-74
Переглянути файл
@@ -1,74 +0,0 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { FileStatus } from "@/bindings";
import type { MenuItem } from "@/ui";
import type { ChangeNode } from "../changes";
vi.mock("@/platform/ipc", async (importOriginal) => {
const real = await importOriginal<typeof import("@/platform/ipc")>();
return { ...real, call: vi.fn() };
});
import { nodeMenu } from "../CommitView";
const file = (rel: string, unstaged: FileStatus["unstaged"] = "modified"): ChangeNode => {
const f: FileStatus = {
path: `/p/${rel}`,
relPath: rel,
staged: null,
unstaged,
renamedFrom: null,
};
return {
key: f.path,
type: "file",
label: rel,
group: "unversioned",
files: [f],
path: f.path,
};
};
const item = (menu: MenuItem[], label: string) =>
menu.find((m) => m.kind !== "separator" && "label" in m && m.label === label);
describe("Add to .gitignore in the changes view", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("offers both destinations in a submenu, as the project view's Git menu does", () => {
const menu = nodeMenu([file("new.txt", "untracked")], ["/p"]);
expect(item(menu, "Add to .gitignore")).toMatchObject({
submenu: [
{
kind: "action",
action: "vcs.ignoreShared",
arg: ["/p/new.txt"],
label: ".gitignore",
},
{
kind: "action",
action: "vcs.ignoreLocal",
arg: ["/p/new.txt"],
label: ".git/info/exclude",
},
],
});
});
it("targets only the unversioned files of a mixed selection", () => {
const menu = nodeMenu([file("a.ts", "modified"), file("new.txt", "untracked")], ["/p"]);
const parent = item(menu, "Add to .gitignore");
expect(parent).toMatchObject({
submenu: [
{ action: "vcs.ignoreShared", arg: ["/p/new.txt"] },
{ action: "vcs.ignoreLocal", arg: ["/p/new.txt"] },
],
});
});
it("offers nothing when no unversioned file is selected", () => {
const menu = nodeMenu([file("a.ts", "modified")], ["/p"]);
expect(item(menu, "Add to .gitignore")).toBeUndefined();
});
});
+2 -2
Переглянути файл
@@ -59,10 +59,10 @@ describe("ignore action", () => {
await addToIgnore(["/p/pkg/a.txt"], "gitignore");
expect(mocks.open).toHaveBeenCalledWith("/p/pkg/.gitignore", { focus: true });
});
it("opens the local exclude file the rule was written to", async () => {
it("opens nothing for the local exclude file", async () => {
mocks.write.mockResolvedValue(["/p/.git/info/exclude"]);
await addToIgnore(["/p/a.txt"], "localExclude");
expect(mocks.open).toHaveBeenCalledWith("/p/.git/info/exclude", { focus: true });
expect(mocks.open).not.toHaveBeenCalled();
});
it("reports an already ignored selection instead of opening an unchanged file", async () => {
mocks.write.mockResolvedValue([]);
+1 -1
Переглянути файл
@@ -22,5 +22,5 @@ export async function addToIgnore(paths: string[], destination: IgnoreDestinatio
}
// Show the rule where it was written: the nearest .gitignore may be a nested one.
const file = changed?.[0];
if (file) await editorService().openFile(file, { focus: true });
if (destination === "gitignore" && file) await editorService().openFile(file, { focus: true });
}
+9 -28
Переглянути файл
@@ -66,39 +66,20 @@ it.each(resizeObserverMessages)("ignores the loop notification delivered as an E
expect(document.getElementById("boot-error")).toBeNull();
});
const reject = (reason: unknown) => {
it.each(resizeObserverMessages)("keeps rejections with the same message fatal: %s", (message) => {
const event = new Event("unhandledrejection");
Object.defineProperty(event, "reason", { value: reason });
Object.defineProperty(event, "reason", { value: message });
window.dispatchEvent(event);
};
it("keeps starting after an unhandled rejection", () => {
reject(new TypeError("Load failed"));
expect(document.getElementById("splash")).not.toBeNull();
expect(document.getElementById("boot-error")).toBeNull();
expect(document.documentElement.dataset.boot).toBeUndefined();
window.dispatchEvent(new Event("openidea:boot-ready"));
vi.advanceTimersByTime(30_000);
expect(document.getElementById("boot-error")).toBeNull();
expect(document.getElementById("splash")).toBeNull();
expect(document.querySelector("textarea")?.value).toContain(message);
});
it("reports the first rejection when startup then times out", () => {
const error = new TypeError("Load failed");
// WebKit's network TypeErrors have no stack; JSON.stringify turns them into "{}".
Object.defineProperty(error, "stack", { value: undefined });
reject(error);
reject({ message: "later rejection" });
vi.advanceTimersByTime(30_000);
const details = document.querySelector("textarea")?.value;
expect(details).toContain("Startup did not finish within 30 seconds.");
expect(details).toContain("TypeError: Load failed");
expect(details).not.toContain("later rejection");
});
it("preserves the first failure", () => {
window.dispatchEvent(new ErrorEvent("error", { error: new Error("startup failed") }));
it("handles startup rejections and preserves the first failure", () => {
const event = new Event("unhandledrejection");
Object.defineProperty(event, "reason", { value: { message: "startup rejected" } });
window.dispatchEvent(event);
window.dispatchEvent(new ErrorEvent("error", { message: "later failure" }));
expect(document.querySelector("textarea")?.value).toContain("startup failed");
expect(document.querySelector("textarea")?.value).toContain("startup rejected");
expect(document.querySelector("textarea")?.value).not.toContain("later failure");
});
-7
Переглянути файл
@@ -13,13 +13,6 @@
align-items: flex-start;
padding-top: 10vh;
}
/* macOS draws its window buttons over the page; keep dialogs out of that band. */
.belowTitleBar {
padding-top: max(24px, var(--h-titlebar));
}
.belowTitleBar.top {
padding-top: max(10vh, var(--h-titlebar));
}
.dialog {
display: flex;
flex-direction: column;
+2 -4
Переглянути файл
@@ -231,7 +231,6 @@ function DialogInner({
}: DialogProps) {
const ref = useRef<HTMLDivElement>(null);
const platform = useDialogPlatform(platformOverride);
const overlayTitleBar = usePlatform((s) => s.overlayTitleBar);
const given = useGivenTx();
if (typeof title === "string") title = given(title);
// Choosers and untitled dialogs (Recent Files, About) are IDEA popups.
@@ -342,7 +341,6 @@ function DialogInner({
const start = { x: e.clientX - offset.x, y: e.clientY - offset.y };
const rect = el.getBoundingClientRect();
const base = { left: rect.left - offset.x, top: rect.top - offset.y };
const minTop = overlayTitleBar && el.parentElement ? parseFloat(getComputedStyle(el.parentElement).paddingTop) : 0;
const move = (ev: globalThis.PointerEvent) => {
if (!(ev.buttons & 1)) return up();
// Keep the title bar reachable.
@@ -350,7 +348,7 @@ function DialogInner({
Math.max(ev.clientX - start.x, -base.left - rect.width + 80),
window.innerWidth - base.left - 80,
);
const y = Math.min(Math.max(ev.clientY - start.y, minTop - base.top), window.innerHeight - base.top - 28);
const y = Math.min(Math.max(ev.clientY - start.y, -base.top), window.innerHeight - base.top - 28);
setOffset({ x, y });
};
const up = () => {
@@ -403,7 +401,7 @@ function DialogInner({
return createPortal(
<div
className={clsx(styles.backdrop, position === "top" && styles.top, overlayTitleBar && styles.belowTitleBar)}
className={clsx(styles.backdrop, position === "top" && styles.top)}
onPointerDown={(e) => {
if ((dismissOnBackdrop ?? popup) && e.target === e.currentTarget) onClose();
}}
+1 -1
Переглянути файл
@@ -215,7 +215,7 @@ function MainMenuBar({ merged, onExpandedChange }: MainMenuProps & { merged: boo
else void expand();
}}
>
<Icon name="main-menu" size={20} />
<Icon name="main-menu" size={16} />
</button>
);
const titles = (
+4 -11
Переглянути файл
@@ -126,16 +126,11 @@
/* Frameless window (Windows, Linux): caption buttons sit flush with the right and top edges. */
.frameless {
padding-right: 0;
/* The main menu button leads the left stripe, so the bar starts where the
stripe's own padding does and the two share a centre line. */
padding-left: var(--stripe-outer-padding);
}
/* The button heads the tool window stripe below it, so it takes the stripe's
size: both shrink in compact mode. */
.mainMenuButton {
flex: none;
width: var(--stripe-icon-button);
height: var(--stripe-icon-button);
width: 30px;
height: 30px;
margin-right: 4px;
padding: 0;
display: inline-flex;
@@ -152,13 +147,11 @@
outline-offset: -2px;
}
/* Preserve the menu's natural width while allowing its slot to yield to toolbar controls. */
/* Ends where the stripe column below it does, the bar's padding being the
stripe's own. */
.mainMenuSlot {
position: relative;
flex: 0 1 auto;
min-width: calc(var(--stripe-icon-button) + var(--island-gap));
height: var(--stripe-icon-button);
min-width: 34px;
height: 30px;
overflow: hidden;
}
.mainMenuSlot ~ .item,