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