Files
tutti/tools/scripts/git-environment.mjs
T
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

45 lines
1.1 KiB
JavaScript

const gitRepositoryEnvironmentVariables = new Set([
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
"GIT_CEILING_DIRECTORIES",
"GIT_COMMON_DIR",
"GIT_CONFIG",
"GIT_CONFIG_COUNT",
"GIT_CONFIG_PARAMETERS",
"GIT_DIR",
"GIT_GRAFT_FILE",
"GIT_IMPLICIT_WORK_TREE",
"GIT_INDEX_FILE",
"GIT_INTERNAL_SUPER_PREFIX",
"GIT_NO_REPLACE_OBJECTS",
"GIT_OBJECT_DIRECTORY",
"GIT_PREFIX",
"GIT_REPLACE_REF_BASE",
"GIT_SHALLOW_FILE",
"GIT_WORK_TREE"
]);
export function createIsolatedGitEnvironment(
fixtureRoot,
inheritedEnvironment = process.env
) {
const env = createGitDiscoveryEnvironment(inheritedEnvironment);
env.GIT_CEILING_DIRECTORIES = fixtureRoot;
return env;
}
export function createGitDiscoveryEnvironment(
inheritedEnvironment = process.env
) {
const env = { ...inheritedEnvironment };
for (const name of Object.keys(env)) {
const normalizedName = name.toUpperCase();
if (
gitRepositoryEnvironmentVariables.has(normalizedName) ||
/^GIT_CONFIG_(?:KEY|VALUE)_\d+$/u.test(normalizedName)
) {
delete env[name];
}
}
return env;
}