mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 15:02:32 +00:00
fix(coding-agent): refresh temporary git extension caches on cache hits
This commit is contained in:
parent
92fdb53c10
commit
310da43042
3 changed files with 101 additions and 2 deletions
|
|
@ -870,6 +870,8 @@ export class DefaultPackageManager implements PackageManager {
|
|||
if (!existsSync(installedPath)) {
|
||||
const installed = await installMissing();
|
||||
if (!installed) continue;
|
||||
} else if (scope === "temporary" && !parsed.pinned) {
|
||||
await this.refreshTemporaryGitSource(parsed, sourceStr);
|
||||
}
|
||||
metadata.baseDir = installedPath;
|
||||
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
||||
|
|
@ -1153,8 +1155,13 @@ export class DefaultPackageManager implements PackageManager {
|
|||
// Fetch latest from remote (handles force-push by getting new history)
|
||||
await this.runCommand("git", ["fetch", "--prune", "origin"], { cwd: targetDir });
|
||||
|
||||
// Reset to upstream tracking branch (handles force-push gracefully)
|
||||
await this.runCommand("git", ["reset", "--hard", "@{upstream}"], { cwd: targetDir });
|
||||
// Reset to tracking branch. Fall back to origin/HEAD when no upstream is configured.
|
||||
try {
|
||||
await this.runCommand("git", ["reset", "--hard", "@{upstream}"], { cwd: targetDir });
|
||||
} catch {
|
||||
await this.runCommand("git", ["remote", "set-head", "origin", "-a"], { cwd: targetDir }).catch(() => {});
|
||||
await this.runCommand("git", ["reset", "--hard", "origin/HEAD"], { cwd: targetDir });
|
||||
}
|
||||
|
||||
// Clean untracked files (extensions should be pristine)
|
||||
await this.runCommand("git", ["clean", "-fdx"], { cwd: targetDir });
|
||||
|
|
@ -1165,6 +1172,16 @@ export class DefaultPackageManager implements PackageManager {
|
|||
}
|
||||
}
|
||||
|
||||
private async refreshTemporaryGitSource(source: GitSource, sourceStr: string): Promise<void> {
|
||||
try {
|
||||
await this.withProgress("pull", sourceStr, `Refreshing ${sourceStr}...`, async () => {
|
||||
await this.updateGit(source, "temporary");
|
||||
});
|
||||
} catch {
|
||||
// Keep cached temporary checkout if refresh fails.
|
||||
}
|
||||
}
|
||||
|
||||
private async removeGit(source: GitSource, scope: SourceScope): Promise<void> {
|
||||
const targetDir = this.getGitInstallPath(source, scope);
|
||||
if (!existsSync(targetDir)) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue