Skip to content

GithubSyncAdapter

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/apps/api/src/git-sync/github-sync.adapter.ts

GithubSyncAdapter — the ONE place B1 talks to GitHub. Reads (refs, trees, blobs, compare) and writes (blobs → tree → commit → fast-forward ref update) via the existing GitHub App installation tokens, exactly like the freshness-PR GitHubWriteAdapter: hand-rolled REST over axios (no octokit in the repo), commits onto the CUSTOMER branch tip via the Git Data API — content, not history; NEVER a force update.

Methods

MethodSignatureReturns
tokenFortokenFor(repoFullName: string)Promise<string>
getBranchTipgetBranchTip(token: string, repoFullName: string, branch: string)`Promise<RemoteTip
commitExistscommitExists(token: string, repoFullName: string, sha: string)Promise<boolean>
comparecompare(token: string, repoFullName: string, base: string, head: string)`Promise<{ status: string; files: RemoteChangedFile[] }
getTreeRecursivegetTreeRecursive(token: string, repoFullName: string, treeSha: string)Promise<RemoteTreeEntry[]>
getFileAtRefgetFileAtRef(token: string, repoFullName: string, path: string, ref: string)`Promise<string
createBlobcreateBlob(token: string, repoFullName: string, content: string)Promise<string>
createTreecreateTree(token: string, repoFullName: string, baseTreeSha: string, entries: NewTreeEntry[])Promise<string>
createCommitcreateCommit(token: string, repoFullName: string, message: string, treeSha: string, parents: string[])Promise<string>
updateRefupdateRef(token: string, repoFullName: string, branch: string, sha: string)Promise<void>

Where it refuses work

  • GithubSyncAdapter stops the work with SyncNotPermittedError when res.status === 403, in 2 places.
  • GithubSyncAdapter stops the work with SyncNotPermittedError when !creds?.password.
  • GithubSyncAdapter stops the work with Error when res.data?.truncated === true.
  • GithubSyncAdapter stops the work with Error when res.status >= 400.
  • GithubSyncAdapter stops the work with an early return when res.status === 404, in 3 places.
  • GithubSyncAdapter stops the work with an early return when ref.status === 404.

Referenced By

  • GitSyncIngestService (DEPENDS_ON)
  • GitSyncModule (MODULE_PROVIDES)
  • GitSyncMirrorService (DEPENDS_ON)

Was this page helpful?

Download as PDF