mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 10:02:23 +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.cwd = options.cwd;
|
||||||
this.agentDir = options.agentDir;
|
this.agentDir = options.agentDir;
|
||||||
this.settingsManager = options.settingsManager;
|
this.settingsManager = options.settingsManager;
|
||||||
this.ensureGitIgnoreDirs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgressCallback(callback: ProgressCallback | undefined): void {
|
setProgressCallback(callback: ProgressCallback | undefined): void {
|
||||||
|
|
@ -623,6 +622,10 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
if (existsSync(targetDir)) {
|
if (existsSync(targetDir)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const gitRoot = this.getGitInstallRoot(scope);
|
||||||
|
if (gitRoot) {
|
||||||
|
this.ensureGitIgnore(gitRoot);
|
||||||
|
}
|
||||||
mkdirSync(dirname(targetDir), { recursive: true });
|
mkdirSync(dirname(targetDir), { recursive: true });
|
||||||
const cloneUrl = source.repo.startsWith("http") ? source.repo : `https://${source.repo}`;
|
const cloneUrl = source.repo.startsWith("http") ? source.repo : `https://${source.repo}`;
|
||||||
await this.runCommand("git", ["clone", cloneUrl, targetDir]);
|
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 {
|
private ensureGitIgnore(dir: string): void {
|
||||||
if (!existsSync(dir)) {
|
if (!existsSync(dir)) {
|
||||||
mkdirSync(dir, { recursive: true });
|
mkdirSync(dir, { recursive: true });
|
||||||
|
|
@ -722,6 +718,16 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
return join(this.agentDir, "git", source.host, source.path);
|
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 {
|
private getTemporaryDir(prefix: string, suffix?: string): string {
|
||||||
const hash = createHash("sha256")
|
const hash = createHash("sha256")
|
||||||
.update(`${prefix}-${suffix ?? ""}`)
|
.update(`${prefix}-${suffix ?? ""}`)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue