MCPcopy
hub / github.com/garrytan/gstack / deriveLegacyCodeSourceId

Function deriveLegacyCodeSourceId

bin/gstack-gbrain-sync.ts:373–382  ·  view source on GitHub ↗

* Pre-pathhash source id, kept for orphan detection only. * * Earlier /sync-gbrain versions registered `gstack-code- ` (no pathhash * suffix). On a multi-worktree repo, those collapsed onto a single source id * with last-sync-wins semantics. The new path-keyed id leaves the legacy * source

(repoPath: string)

Source from the content-addressed store, hash-verified

371 * sync from any worktree of this repo, so users don't accumulate orphans.
372 */
373function deriveLegacyCodeSourceId(repoPath: string): string {
374 const remote = canonicalizeRemote(originUrl());
375 if (remote) {
376 const segs = remote.split("/").filter(Boolean);
377 const slugSource = segs.slice(-2).join("-");
378 return constrainSourceId("gstack-code", slugSource);
379 }
380 const base = repoPath.split("/").pop() || "repo";
381 return constrainSourceId("gstack-code", base);
382}
383
384/**
385 * Pre-#1468 path-only-hash source id, kept for hostname-fold migration only.

Callers 1

runCodeImportFunction · 0.85

Calls 3

canonicalizeRemoteFunction · 0.90
originUrlFunction · 0.85
constrainSourceIdFunction · 0.85

Tested by

no test coverage detected