MCPcopy Create free account
hub / github.com/dyoshikawa/rulesync / resolveGithubFetchRef

Function resolveGithubFetchRef

src/lib/sources.ts:489–512  ·  view source on GitHub ↗

* Resolve a GitHub source's ref to a commit SHA, preferring the locked SHA for * deterministic fetches and otherwise resolving the declared ref or default * branch. Returns the on-disk `ref` (SHA when freshly resolved, else locked * ref), the resolved SHA, and the requested ref.

(params: {
  parsed: ParsedSource;
  locked: LockedSource | undefined;
  updateSources: boolean;
  sourceKey: string;
  client: GitHubClient;
  logger: Logger;
})

Source from the content-addressed store, hash-verified

487 * ref), the resolved SHA, and the requested ref.
488 */
489async function resolveGithubFetchRef(params: {
490 parsed: ParsedSource;
491 locked: LockedSource | undefined;
492 updateSources: boolean;
493 sourceKey: string;
494 client: GitHubClient;
495 logger: Logger;
496}): Promise<{ ref: string; resolvedSha: string; requestedRef: string | undefined }> {
497 const { parsed, locked, updateSources, sourceKey, client, logger } = params;
498 if (locked && !updateSources) {
499 // Use the locked SHA for deterministic fetching
500 logger.debug(`Using locked ref for ${sourceKey}: ${locked.resolvedRef}`);
501 return {
502 ref: locked.resolvedRef,
503 resolvedSha: locked.resolvedRef,
504 requestedRef: locked.requestedRef,
505 };
506 }
507 // Resolve the ref (or default branch) to a SHA
508 const requestedRef = parsed.ref ?? (await client.getDefaultBranch(parsed.owner, parsed.repo));
509 const resolvedSha = await client.resolveRefToSha(parsed.owner, parsed.repo, requestedRef);
510 logger.debug(`Resolved ${sourceKey} ref "${requestedRef}" to SHA: ${resolvedSha}`);
511 return { ref: resolvedSha, resolvedSha, requestedRef };
512}
513
514/**
515 * Fallback path used when an explicit single-skill source points at a flat skill

Callers 1

fetchSourceFunction · 0.85

Calls 3

debugMethod · 0.45
getDefaultBranchMethod · 0.45
resolveRefToShaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…