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

Method checkMetadataRef

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

Source from the content-addressed store, hash-verified

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