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

Function derivePathOnlyHashLegacyId

bin/gstack-gbrain-sync.ts:396–406  ·  view source on GitHub ↗
(repoPath: string)

Source from the content-addressed store, hash-verified

394 * both probes run.
395 */
396export function derivePathOnlyHashLegacyId(repoPath: string): string {
397 const pathHash = createHash("sha1").update(repoPath).digest("hex").slice(0, 8);
398 const remote = canonicalizeRemote(originUrl());
399 if (remote) {
400 const segs = remote.split("/").filter(Boolean);
401 const slugSource = segs.slice(-2).join("-");
402 return constrainSourceId("gstack-code", `${slugSource}-${pathHash}`);
403 }
404 const base = repoPath.split("/").pop() || "repo";
405 return constrainSourceId("gstack-code", `${base}-${pathHash}`);
406}
407
408/**
409 * Feature-check whether the installed gbrain CLI ships `sources rename <old> <new>`.

Callers 2

runCodeImportFunction · 0.85

Calls 3

canonicalizeRemoteFunction · 0.90
originUrlFunction · 0.85
constrainSourceIdFunction · 0.85

Tested by

no test coverage detected