()
| 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 |
no test coverage detected