(
codeReview: adapterTypes.CodeReview & { sourceSha: string; targetSha: string },
)
| 20 | |
| 21 | // get the change files of a codeReview |
| 22 | export const getCodeReviewChangedFiles = async ( |
| 23 | codeReview: adapterTypes.CodeReview & { sourceSha: string; targetSha: string }, |
| 24 | ) => { |
| 25 | const scheme = adapterManager.getCurrentScheme(); |
| 26 | const { repo } = await router.getState(); |
| 27 | const baseRootUri = vscode.Uri.parse('').with({ |
| 28 | scheme: scheme, |
| 29 | authority: `${repo}+${codeReview.targetSha}`, |
| 30 | path: '/', |
| 31 | }); |
| 32 | const headRootUri = baseRootUri.with({ |
| 33 | authority: `${repo}+${codeReview.sourceSha}`, |
| 34 | }); |
| 35 | |
| 36 | const repository = Repository.getInstance(scheme, repo); |
| 37 | const changedFiles = await repository.getCodeReviewChangedFiles(codeReview.id); |
| 38 | |
| 39 | return changedFiles.map((changedFile) => { |
| 40 | // the `previous_filename` field only exists in `RENAMED` file, |
| 41 | // fallback to `filename` otherwise |
| 42 | const baseFilePath = changedFile.previousPath || changedFile.path; |
| 43 | const headFilePath = changedFile.path; |
| 44 | return { |
| 45 | baseFileUri: vscode.Uri.joinPath(baseRootUri, baseFilePath), |
| 46 | headFileUri: vscode.Uri.joinPath(headRootUri, headFilePath), |
| 47 | status: changedFile.status, |
| 48 | }; |
| 49 | }); |
| 50 | }; |
| 51 | |
| 52 | export const getCommitChangedFiles = async (commit: adapterTypes.Commit) => { |
| 53 | const currentAdapter = adapterManager.getCurrentAdapter(); |
no test coverage detected