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

Method checkMetadataRef

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

Source from the content-addressed store, hash-verified

403 }
404
405 checkMetadataRef() {
406 return this.request(`${this.repoURL}/git/refs/meta/_decap_cms`)
407 .then(response => response.object)
408 .catch(() => {
409 // Meta ref doesn't exist
410 const readme = {
411 raw: '# Decap CMS\n\nThis tree is used by the Decap CMS to store metadata information for specific files and branches.',
412 };
413
414 return this.uploadBlob(readme)
415 .then(item =>
416 this.request(`${this.repoURL}/git/trees`, {
417 method: 'POST',
418 body: JSON.stringify({
419 tree: [{ path: 'README.md', mode: '100644', type: 'blob', sha: item.sha }],
420 }),
421 }),
422 )
423 .then(tree => this.commit('First Commit', tree))
424 .then(response => this.createRef('meta', '_decap_cms', response.sha))
425 .then(response => response.object);
426 });
427 }
428
429 async storeMetadata(key: string, data: Metadata) {
430 // 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