Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conflict resolution for files that are added in both #5981

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/view/gitHubContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ import { GitHubRepository } from '../github/githubRepository';

export async function getGitHubFileContent(gitHubRepository: GitHubRepository, fileName: string, ref: string): Promise<Uint8Array> {
const { octokit, remote } = await gitHubRepository.ensure();
let fileContent: { data: { content: string; encoding: string; sha: string } } = (await octokit.call(octokit.api.repos.getContent,
{
owner: remote.owner,
repo: remote.repositoryName,
path: fileName,
ref,
},
)) as any;
let contents = fileContent.data.content ?? '';
let contents: string = '';
let fileContent: { data: { content: string; encoding: string; sha: string } };
try {
fileContent = (await octokit.call(octokit.api.repos.getContent,
{
owner: remote.owner,
repo: remote.repositoryName,
path: fileName,
ref,
},
)) as any;
contents = fileContent.data.content ?? '';
} catch (e) {
if (e.status === 404) {
return new Uint8Array(0);
}
throw e;
}

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