* Resolves the branch to fetch a single repository file from in getDocument. Uses * the configured branch override when set, otherwise the repository's default * branch (resolved from the cached or freshly-listed repository record).
( accessToken: string, organization: string, project: string, repoId: string, branchOverride: string, syncContext?: Record<string, unknown> )
| 996 | * branch (resolved from the cached or freshly-listed repository record). |
| 997 | */ |
| 998 | async function resolveFileBranch( |
| 999 | accessToken: string, |
| 1000 | organization: string, |
| 1001 | project: string, |
| 1002 | repoId: string, |
| 1003 | branchOverride: string, |
| 1004 | syncContext?: Record<string, unknown> |
| 1005 | ): Promise<{ branch: string; repo?: GitRepository }> { |
| 1006 | if (branchOverride) { |
| 1007 | const repos = (syncContext?.repositories as GitRepository[] | undefined) ?? [] |
| 1008 | return { branch: branchOverride, repo: repos.find((r) => r.id === repoId) } |
| 1009 | } |
| 1010 | const repos = |
| 1011 | (syncContext?.repositories as GitRepository[] | undefined) ?? |
| 1012 | (await listRepositories(accessToken, organization, project)) |
| 1013 | if (syncContext && !syncContext.repositories) syncContext.repositories = repos |
| 1014 | const repo = repos.find((r) => r.id === repoId) |
| 1015 | return { branch: stripRefsHeads(repo?.defaultBranch ?? ''), repo } |
| 1016 | } |
| 1017 | |
| 1018 | /** |
| 1019 | * Fetches and hydrates a single repository file by its externalId. Re-fetches the |
no test coverage detected