Файли
openidea/src/features/vcs/gitIdentity.ts
T
l0ng-ai 401c542647 feat(vcs): improve Git workflows (#5174)
Improve OpenIDEA's Git workflows across commit and staging, branch and remote operations, merge and rebase, Git Log and signing, worktrees, stash and shelf, patch application, and clone settings. Adds a one-click stash for tracked changes across Git roots and lets users open a worktree branch's associated GitHub review from its context menu. Cloning now includes submodules by default (Settings › Version Control › Git, can be turned off).

Repository entry points added here run in each repository's execution scope, so they use the project's own git executable.
2026-11-22 21:57:30 +08:00

20 рядки
792 B
TypeScript

import { call, commands } from "@/platform/ipc";
export async function readConfiguredGitIdentity(root: string | null) {
const get = (key: string) =>
call(commands.vcsConfigGet(root, key)).then(
(value) => value?.trim() || null,
() => null,
);
const [name, email] = await Promise.all([get("user.name"), get("user.email")]);
return { name, email };
}
/** Identifies the person by name, falling back to the email's local part. */
export function gitPersonKey(name: string | null | undefined, email?: string | null): string {
const at = email?.indexOf("@") ?? -1;
const person = name || (at > 0 ? email?.slice(0, at) : email) || "";
if (/[^\x20-\x7e]/.test(person)) return person;
return person.toLowerCase().replace(/^(\w+)[\s\p{P}\p{S}](\w+)$/u, "$1 $2");
}