Skip to content

Commit 92338e3

Browse files
authored
Fix conflict resolution for files that are added in both (#5981)
Fixes #5943
1 parent ee0093c commit 92338e3

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

src/view/gitHubContentProvider.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@ import { GitHubRepository } from '../github/githubRepository';
1212

1313
export async function getGitHubFileContent(gitHubRepository: GitHubRepository, fileName: string, ref: string): Promise<Uint8Array> {
1414
const { octokit, remote } = await gitHubRepository.ensure();
15-
let fileContent: { data: { content: string; encoding: string; sha: string } } = (await octokit.call(octokit.api.repos.getContent,
16-
{
17-
owner: remote.owner,
18-
repo: remote.repositoryName,
19-
path: fileName,
20-
ref,
21-
},
22-
)) as any;
23-
let contents = fileContent.data.content ?? '';
15+
let contents: string = '';
16+
let fileContent: { data: { content: string; encoding: string; sha: string } };
17+
try {
18+
fileContent = (await octokit.call(octokit.api.repos.getContent,
19+
{
20+
owner: remote.owner,
21+
repo: remote.repositoryName,
22+
path: fileName,
23+
ref,
24+
},
25+
)) as any;
26+
contents = fileContent.data.content ?? '';
27+
} catch (e) {
28+
if (e.status === 404) {
29+
return new Uint8Array(0);
30+
}
31+
throw e;
32+
}
2433

2534
// Empty contents and 'none' encoding indcates that the file has been truncated and we should get the blob.
2635
if (contents === '' && fileContent.data.encoding === 'none') {

0 commit comments

Comments
 (0)