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

Method checkMetadataRef

packages/decap-cms-backend-github/src/API.ts:430–452  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

428 }
429
430 checkMetadataRef() {
431 return this.request(`${this.repoURL}/git/refs/meta/_decap_cms`)
432 .then(response => response.object)
433 .catch(() => {
434 // Meta ref doesn't exist
435 const readme = {
436 raw: '# Decap CMS\n\nThis tree is used by the Decap CMS to store metadata information for specific files and branches.',
437 };
438
439 return this.uploadBlob(readme)
440 .then(item =>
441 this.request(`${this.repoURL}/git/trees`, {
442 method: 'POST',
443 body: JSON.stringify({
444 tree: [{ path: 'README.md', mode: '100644', type: 'blob', sha: item.sha }],
445 }),
446 }),
447 )
448 .then(tree => this.commit('First Commit', tree))
449 .then(response => this.createRef('meta', '_decap_cms', response.sha))
450 .then(response => response.object);
451 });
452 }
453
454 async storeMetadata(key: string, data: Metadata) {
455 // semaphore ensures metadata updates are always ordered, even if

Callers 2

storeMetadataMethod · 0.95
deleteMetadataMethod · 0.95

Calls 4

requestMethod · 0.95
uploadBlobMethod · 0.95
commitMethod · 0.95
createRefMethod · 0.95

Tested by

no test coverage detected