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