Skip to content

Commit

Permalink
feat(react-tinacms-github): GithubFile: Support committing newly crea…
Browse files Browse the repository at this point in the history
…ted files
  • Loading branch information
zenflow committed Dec 18, 2020
1 parent 7e3ba86 commit d13eb76
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/react-tinacms-github/src/github-client/GithubFile.ts
Expand Up @@ -45,11 +45,20 @@ export class GithubFile {
retryOnConflict = true
) => {
const serializedContent = this.serialize ? this.serialize(data) : data
try {
if (!this.sha) {
if (!this.sha) {
try {
const res = await this.cms.api.github.fetchFile(this.path)
this.sha = res.sha
} catch (error) {
if (error.status === 404) {
this.sha = ''
} else {
this.cms.events.dispatch({ type: ERROR, error })
throw error
}
}
}
try {
const response = await this.cms.api.github.commit(
this.path,
this.sha,
Expand Down

0 comments on commit d13eb76

Please sign in to comment.