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

Method getFileContent

src/lib/github-client.ts:144–170  ·  view source on GitHub ↗

* Get raw file content from a repository

(owner: string, repo: string, path: string, ref?: string)

Source from the content-addressed store, hash-verified

142 * Get raw file content from a repository
143 */
144 async getFileContent(owner: string, repo: string, path: string, ref?: string): Promise<string> {
145 try {
146 const { data } = await this.octokit.repos.getContent({
147 owner,
148 repo,
149 path,
150 ref,
151 mediaType: {
152 format: "raw",
153 },
154 });
155
156 // When using raw format, data is returned as a string
157 if (typeof data === "string") {
158 return data;
159 }
160
161 // Fallback: if data is an object with content (base64 encoded)
162 if (!Array.isArray(data) && "content" in data && data.content) {
163 return Buffer.from(data.content, "base64").toString("utf-8");
164 }
165
166 throw new GitHubClientError(`Unexpected response format for file content`);
167 } catch (error) {
168 throw this.handleError(error);
169 }
170 }
171
172 /**
173 * Check if a file exists and is within size limits

Callers 15

fetchFilesFunction · 0.95
writeAiFilesFunction · 0.45
tool-file.test.tsFile · 0.45
fetchGithubSkillDirFunction · 0.45
processFeatureConversionFunction · 0.45
fetchAndConvertToolFilesFunction · 0.45
putCommandFunction · 0.45
getMcpFileFunction · 0.45
putMcpFileFunction · 0.45

Calls 1

handleErrorMethod · 0.95

Tested by

no test coverage detected