дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Subversion requests from #7433: - Shelve, Shelve Silently, Unshelve and the Shelf tab work in Subversion working copies. Shelve saves `svn diff --git --show-copies-as-adds` of the selection and rolls the files back, refusing when the files changed since the patch was taken; Unshelve applies it with `svn patch` and reports rejected or skipped files as conflicts. Unversioned or conflicted files, binary files an older svn cannot put in a patch, non-UTF-8 text and selections across working copies are refused before anything is reverted. Stash stays Git-only. - A Subversion Working Copies Information tab lists every working copy with its URL, repository root, revision, depth and format, with Show Log, Update Project, Cleanup and Relocate for each. - The version control menu is named SVN for a Subversion project and VCS for a project with several systems. - The version control tool window button is last in the bottom stripe group. Co-authored-by: wildcatDownstairs <[email protected]>
98 рядки
3.2 KiB
TypeScript
98 рядки
3.2 KiB
TypeScript
/**
|
||
* Settings › Version Control › Git › Enable Git integration. Off, the backend finds no
|
||
* repositories and refuses the commands that start git on their own (clone, init, GitHub);
|
||
* the frontend leaves out every Git action, tool window and menu.
|
||
*/
|
||
import { create } from "zustand";
|
||
import { setContext } from "./context";
|
||
import { onWorkflowSettingsChange, useWorkflowSettings, workflowSettings } from "./workflowSettings";
|
||
|
||
export function gitEnabled(): boolean {
|
||
return workflowSettings().vcs.git.enabled;
|
||
}
|
||
|
||
export function useGitEnabled(): boolean {
|
||
return useWorkflowSettings((w) => w.vcs.git.enabled);
|
||
}
|
||
|
||
/**
|
||
* Keeps the `gitDisabled` context key (for `when` clauses) in step with the setting.
|
||
* Unset it reads as enabled, so a window that never installs it keeps its Git actions.
|
||
*/
|
||
export function installGitEnabledContext(): () => void {
|
||
setContext("gitDisabled", !gitEnabled());
|
||
const off = onWorkflowSettingsChange(
|
||
(w) => w.vcs.git.enabled,
|
||
(on) => setContext("gitDisabled", !on),
|
||
);
|
||
return () => {
|
||
off();
|
||
setContext("gitDisabled", false);
|
||
};
|
||
}
|
||
|
||
/** Runs `register` while Git integration is on and disposes what it registered while it is off. */
|
||
export function whileGitEnabled(register: () => () => void): () => void {
|
||
let dispose: (() => void) | null = null;
|
||
const sync = (on: boolean) => {
|
||
if (on && !dispose) dispose = register();
|
||
else if (!on && dispose) {
|
||
dispose();
|
||
dispose = null;
|
||
}
|
||
};
|
||
sync(gitEnabled());
|
||
const off = onWorkflowSettingsChange((w) => w.vcs.git.enabled, sync);
|
||
return () => {
|
||
off();
|
||
dispose?.();
|
||
dispose = null;
|
||
};
|
||
}
|
||
|
||
/**
|
||
* The project has a working copy of another system (Subversion), which Enable Git integration
|
||
* does not turn off: the shared version control UI (Commit, log, annotate) stays for it, and
|
||
* what only Git has is hidden by the root's system (`vcsKind`).
|
||
*/
|
||
/**
|
||
* `menu`: the version control menu's name, as IDEA names it: the project's one system (`git`,
|
||
* `svn`), else `vcs`.
|
||
*/
|
||
export type VcsMenuName = "git" | "svn" | "vcs";
|
||
|
||
export const useOtherVcsRoots = create<{ present: boolean; menu: VcsMenuName }>(() => ({
|
||
present: false,
|
||
menu: "git",
|
||
}));
|
||
|
||
export function setOtherVcsRoots(present: boolean, menu: VcsMenuName = "git"): void {
|
||
const s = useOtherVcsRoots.getState();
|
||
if (s.present !== present || s.menu !== menu) useOtherVcsRoots.setState({ present, menu });
|
||
}
|
||
|
||
/** Git integration is on, or the project has a working copy of another system. */
|
||
export function vcsEnabled(): boolean {
|
||
return gitEnabled() || useOtherVcsRoots.getState().present;
|
||
}
|
||
|
||
/** [`whileGitEnabled`] for what other systems share with Git: on while [`vcsEnabled`]. */
|
||
export function whileVcsEnabled(register: () => () => void): () => void {
|
||
let dispose: (() => void) | null = null;
|
||
const sync = () => {
|
||
const on = vcsEnabled();
|
||
if (on && !dispose) dispose = register();
|
||
else if (!on && dispose) {
|
||
dispose();
|
||
dispose = null;
|
||
}
|
||
};
|
||
sync();
|
||
const offs = [onWorkflowSettingsChange((w) => w.vcs.git.enabled, sync), useOtherVcsRoots.subscribe(sync)];
|
||
return () => {
|
||
offs.forEach((off) => off());
|
||
dispose?.();
|
||
dispose = null;
|
||
};
|
||
}
|