mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 09:01:14 +00:00
Defer create .gitignore
This commit is contained in:
parent
151099e17e
commit
48020405f3
1 changed files with 14 additions and 8 deletions
|
|
@ -259,7 +259,6 @@ export class DefaultPackageManager implements PackageManager {
|
|||
this.cwd = options.cwd;
|
||||
this.agentDir = options.agentDir;
|
||||
this.settingsManager = options.settingsManager;
|
||||
this.ensureGitIgnoreDirs();
|
||||
}
|
||||
|
||||
setProgressCallback(callback: ProgressCallback | undefined): void {
|
||||
|
|
@ -623,6 +622,10 @@ export class DefaultPackageManager implements PackageManager {
|
|||
if (existsSync(targetDir)) {
|
||||
return;
|
||||
}
|
||||
const gitRoot = this.getGitInstallRoot(scope);
|
||||
if (gitRoot) {
|
||||
this.ensureGitIgnore(gitRoot);
|
||||
}
|
||||
mkdirSync(dirname(targetDir), { recursive: true });
|
||||
const cloneUrl = source.repo.startsWith("http") ? source.repo : `https://${source.repo}`;
|
||||
await this.runCommand("git", ["clone", cloneUrl, targetDir]);
|
||||
|
|
@ -666,13 +669,6 @@ export class DefaultPackageManager implements PackageManager {
|
|||
}
|
||||
}
|
||||
|
||||
private ensureGitIgnoreDirs(): void {
|
||||
this.ensureGitIgnore(join(this.agentDir, "git"));
|
||||
this.ensureGitIgnore(join(this.agentDir, "npm"));
|
||||
this.ensureGitIgnore(join(this.cwd, CONFIG_DIR_NAME, "git"));
|
||||
this.ensureGitIgnore(join(this.cwd, CONFIG_DIR_NAME, "npm"));
|
||||
}
|
||||
|
||||
private ensureGitIgnore(dir: string): void {
|
||||
if (!existsSync(dir)) {
|
||||
mkdirSync(dir, { recursive: true });
|
||||
|
|
@ -722,6 +718,16 @@ export class DefaultPackageManager implements PackageManager {
|
|||
return join(this.agentDir, "git", source.host, source.path);
|
||||
}
|
||||
|
||||
private getGitInstallRoot(scope: SourceScope): string | undefined {
|
||||
if (scope === "temporary") {
|
||||
return undefined;
|
||||
}
|
||||
if (scope === "project") {
|
||||
return join(this.cwd, CONFIG_DIR_NAME, "git");
|
||||
}
|
||||
return join(this.agentDir, "git");
|
||||
}
|
||||
|
||||
private getTemporaryDir(prefix: string, suffix?: string): string {
|
||||
const hash = createHash("sha256")
|
||||
.update(`${prefix}-${suffix ?? ""}`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue