MCPcopy Create free account
hub / github.com/decaporg/decap-cms / getFileSha

Method getFileSha

packages/decap-cms-backend-forgejo/src/API.ts:502–518  ·  view source on GitHub ↗
(path: string, { repoURL = this.repoURL, branch = this.branch } = {})

Source from the content-addressed store, hash-verified

500 }
501
502 async getFileSha(path: string, { repoURL = this.repoURL, branch = this.branch } = {}) {
503 // Normalize path by removing leading slash if present
504 const normalizedPath = path.startsWith('/') ? path.slice(1) : path;
505 const encodedPath = normalizedPath
506 .split('/')
507 .map(segment => encodeURIComponent(segment))
508 .join('/');
509 const result = (await this.request(`${repoURL}/contents/${encodedPath}`, {
510 params: { ref: branch },
511 })) as { sha?: string };
512
513 if (result?.sha) {
514 return result.sha;
515 }
516
517 throw new APIError('Not Found', 404, API_NAME);
518 }
519
520 async deleteFiles(paths: string[], message: string) {
521 if (this.useOpenAuthoring) {

Callers 3

readFileMethod · 0.95
deleteFilesMethod · 0.95

Calls 2

requestMethod · 0.95
mapMethod · 0.80

Tested by

no test coverage detected