(commit: adapterTypes.Commit)
| 50 | }; |
| 51 | |
| 52 | export const getCommitChangedFiles = async (commit: adapterTypes.Commit) => { |
| 53 | const currentAdapter = adapterManager.getCurrentAdapter(); |
| 54 | const scheme = currentAdapter.scheme; |
| 55 | const { repo } = await router.getState(); |
| 56 | // if the commit.parents is more than one element |
| 57 | // the parents[1].sha should be the merge source commitSha |
| 58 | // so we use the parents[0].sha as the parent commitSha |
| 59 | const baseRef = commit?.parents?.[0]; |
| 60 | const baseRootUri = vscode.Uri.parse('').with({ |
| 61 | scheme: currentAdapter.scheme, |
| 62 | authority: `${repo}+${baseRef || 'HEAD'}`, |
| 63 | path: '/', |
| 64 | }); |
| 65 | const headRootUri = baseRootUri.with({ |
| 66 | authority: `${repo}+${commit.sha || 'HEAD'}`, |
| 67 | }); |
| 68 | const repository = Repository.getInstance(scheme, repo); |
| 69 | const changedFiles = await repository.getCommitChangedFiles(commit.sha); |
| 70 | |
| 71 | return changedFiles.map((commitFile) => { |
| 72 | // the `previous_filename` field only exists in `RENAMED` file, |
| 73 | // fallback to `filename` otherwise |
| 74 | const baseFilePath = commitFile.previousPath || commitFile.path; |
| 75 | const headFilePath = commitFile.path; |
| 76 | return { |
| 77 | baseFileUri: vscode.Uri.joinPath(baseRootUri, baseFilePath), |
| 78 | headFileUri: vscode.Uri.joinPath(headRootUri, headFilePath), |
| 79 | status: commitFile.status, |
| 80 | }; |
| 81 | }); |
| 82 | }; |
| 83 | |
| 84 | export const getChangedFiles = async (): Promise<VSCodeChangedFile[]> => { |
| 85 | const routerState = await router.getState(); |
no test coverage detected