дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Settings > Version Control > Git gets an Enable Git integration master toggle (global, on by default). While it is off the IDE discovers no repositories and runs no git: status, log, blame, fetch, clone, GitHub, the MCP git tools, plugin repository access and agent worktrees refuse to run, and the Git menu, Get from Version Control, the Git, Commit and GitHub Actions tool windows, Git actions and the branch widget are hidden. Turning it back on restores them without reopening the project. Settings pages gain a reusable master toggle that disables the page's sections, and MenuConfig gains a hidden list applied to the native and in-app menus. Co-authored-by: bertyhell <[email protected]>
51 рядки
1.6 KiB
TypeScript
51 рядки
1.6 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 { 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;
|
||
};
|
||
}
|