MCPcopy Create free account
hub / github.com/angular/dev-infra / getFile

Function getFile

github-actions/org-file-sync/lib/main.ts:45–62  ·  view source on GitHub ↗

* Retrieve the file content for a specified file, properly handling the file not existing in the * repo and returning a 404.

(github: Octokit, repo: string, path: string)

Source from the content-addressed store, hash-verified

43 * repo and returning a 404.
44 */
45async function getFile(github: Octokit, repo: string, path: string): Promise<File | null> {
46 core.info(`Retrieving "${path}" from ${repo} repo`);
47 return github.rest.repos.getContent({owner: context.repo.owner, repo, path}).then(
48 (response) => {
49 if ((response.data as {content?: string}).content !== undefined) {
50 return response.data as File;
51 }
52 return null;
53 },
54 (reason: RequestError) => {
55 if (reason.status === 404) {
56 core.warning(`"${path}" does not exist in "${repo}" repo`);
57 return null;
58 }
59 throw reason;
60 },
61 );
62}
63
64/**
65 * Update the target repo to ensure the provided golden file contents are used for the files

Callers 1

getFilesForRepoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected