дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 11:15:40 +02:00
Unversioned files and folders in the Commit tool window's changes menu offer Add to .gitignore / Add to .git/info/exclude, the same action as the Project view's Git submenu. vcs_add_to_ignore returns the ignore files it changed and the IDE opens the nearest one after writing. A selected symlink or Windows junction is ignored by name without a trailing slash; symlinked ancestors are still refused, and already-ignored paths are left unchanged. Co-authored-by: guoyucode <[email protected]>
27 рядки
1.2 KiB
TypeScript
27 рядки
1.2 KiB
TypeScript
/** Project-host ignore writes; shared by the project menu and Find Action. */
|
|
import type { IgnoreDestination } from "@/bindings";
|
|
import { call, commands } from "@/platform/ipc";
|
|
import { reloadAll } from "@/features/project-tree/store";
|
|
import { editorService, notifications } from "@/workbench/contributions";
|
|
import { runOp } from "./ops";
|
|
import { refreshNow } from "./store";
|
|
|
|
export async function addToIgnore(paths: string[], destination: IgnoreDestination) {
|
|
if (!paths.length) return;
|
|
const changed = await runOp(
|
|
destination === "gitignore" ? "Add to .gitignore" : "Add to .git/info/exclude",
|
|
() => call(commands.vcsAddToIgnore(paths, destination)),
|
|
{ refresh: false },
|
|
);
|
|
// Also refresh after a partial failure in a multi-repository selection.
|
|
await Promise.all([refreshNow(), reloadAll()]);
|
|
if (changed && !changed.length) {
|
|
// Existing rules already cover the selection (e.g. a `_*/` directory pattern).
|
|
notifications().notify({ group: "vcs", level: "info", title: "Already ignored" });
|
|
return;
|
|
}
|
|
// Show the rule where it was written: the nearest .gitignore may be a nested one.
|
|
const file = changed?.[0];
|
|
if (destination === "gitignore" && file) await editorService().openFile(file, { focus: true });
|
|
}
|