diff --git a/extension/src/service-worker/__tests__/git-host.test.ts b/extension/src/service-worker/__tests__/git-host.test.ts index f177cfa..5aae457 100644 --- a/extension/src/service-worker/__tests__/git-host.test.ts +++ b/extension/src/service-worker/__tests__/git-host.test.ts @@ -55,6 +55,7 @@ describe('GitHubHost.putBlob', () => { expect(fetchMock).toHaveBeenCalledTimes(6); expect(fetchMock.mock.calls[0][0]).toContain('/git/blobs'); expect(fetchMock.mock.calls[1][0]).toContain('/git/refs/heads/'); + expect(fetchMock.mock.calls[2][0]).toContain('/git/commits/'); expect(fetchMock.mock.calls[3][0]).toContain('/git/trees'); expect(fetchMock.mock.calls[4][0]).toContain('/git/commits'); expect(fetchMock.mock.calls[5][1]?.method).toBe('PATCH'); diff --git a/extension/src/service-worker/github.ts b/extension/src/service-worker/github.ts index c3f2748..0ee250c 100644 --- a/extension/src/service-worker/github.ts +++ b/extension/src/service-worker/github.ts @@ -135,14 +135,16 @@ export class GitHubHost implements GitHost { // 2. Get current ref (branch tip commit SHA). const refResp = await fetch(`${this.gitApiBase}/refs/heads/${this.branch}`, { headers: this.headers }); if (!refResp.ok) { - throw new Error(`GitHub putBlob get-ref ${this.branch}: ${refResp.status} ${refResp.statusText}`); + const text = await refResp.text(); + throw new Error(`GitHub putBlob get-ref ${this.branch}: ${refResp.status} ${text}`); } const { object: { sha: commitSha } } = await refResp.json() as { object: { sha: string } }; // 3. Get current commit's tree SHA. const commitResp = await fetch(`${this.gitApiBase}/commits/${commitSha}`, { headers: this.headers }); if (!commitResp.ok) { - throw new Error(`GitHub putBlob get-commit ${commitSha}: ${commitResp.status} ${commitResp.statusText}`); + const text = await commitResp.text(); + throw new Error(`GitHub putBlob get-commit ${commitSha}: ${commitResp.status} ${text}`); } const { tree: { sha: baseTreeSha } } = await commitResp.json() as { tree: { sha: string } };