Defer create .gitignore
This commit is contained in:
@@ -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 ?? ""}`)
|
||||
|
||||
Reference in New Issue
Block a user