mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-05 19:01:12 -07:00
This commit is contained in:
@@ -51,6 +51,16 @@ export class GitService {
|
||||
}
|
||||
}
|
||||
|
||||
private getShadowRepoEnv(repoDir: string) {
|
||||
const gitConfigPath = path.join(repoDir, '.gitconfig');
|
||||
const systemConfigPath = path.join(repoDir, '.gitconfig_system_empty');
|
||||
return {
|
||||
// Prevent git from using the user's global git config.
|
||||
GIT_CONFIG_GLOBAL: gitConfigPath,
|
||||
GIT_CONFIG_SYSTEM: systemConfigPath,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a hidden git repository in the project root.
|
||||
* The Git repository is used to support checkpointing.
|
||||
@@ -67,7 +77,9 @@ export class GitService {
|
||||
'[user]\n name = Gemini CLI\n email = gemini-cli@google.com\n[commit]\n gpgsign = false\n';
|
||||
await fs.writeFile(gitConfigPath, gitConfigContent);
|
||||
|
||||
const repo = simpleGit(repoDir);
|
||||
const shadowRepoEnv = this.getShadowRepoEnv(repoDir);
|
||||
await fs.writeFile(shadowRepoEnv.GIT_CONFIG_SYSTEM, '');
|
||||
const repo = simpleGit(repoDir).env(shadowRepoEnv);
|
||||
let isRepoDefined = false;
|
||||
try {
|
||||
isRepoDefined = await repo.checkIsRepo(CheckRepoActions.IS_REPO_ROOT);
|
||||
@@ -107,9 +119,7 @@ export class GitService {
|
||||
return simpleGit(this.projectRoot).env({
|
||||
GIT_DIR: path.join(repoDir, '.git'),
|
||||
GIT_WORK_TREE: this.projectRoot,
|
||||
// Prevent git from using the user's global git config.
|
||||
HOME: repoDir,
|
||||
XDG_CONFIG_HOME: repoDir,
|
||||
...this.getShadowRepoEnv(repoDir),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user