( repository: Repository, file: FileChange, baseBranchName: string, comparisonBranchName: string, hideWhitespaceInDiff: boolean = false, latestCommit: string )
| 152 | * (Show what would be the result of merge) |
| 153 | */ |
| 154 | export async function getBranchMergeBaseDiff( |
| 155 | repository: Repository, |
| 156 | file: FileChange, |
| 157 | baseBranchName: string, |
| 158 | comparisonBranchName: string, |
| 159 | hideWhitespaceInDiff: boolean = false, |
| 160 | latestCommit: string |
| 161 | ): Promise<IDiff> { |
| 162 | const args = [ |
| 163 | 'diff', |
| 164 | '--merge-base', |
| 165 | baseBranchName, |
| 166 | comparisonBranchName, |
| 167 | ...(hideWhitespaceInDiff ? ['-w'] : []), |
| 168 | '--patch-with-raw', |
| 169 | '-z', |
| 170 | '--no-color', |
| 171 | '--', |
| 172 | ensureRelativePath(file.path), |
| 173 | ] |
| 174 | |
| 175 | if ( |
| 176 | file.status.kind === AppFileStatusKind.Renamed || |
| 177 | file.status.kind === AppFileStatusKind.Copied |
| 178 | ) { |
| 179 | args.push(ensureRelativePath(file.status.oldPath)) |
| 180 | } |
| 181 | |
| 182 | const result = await git(args, repository.path, 'getBranchMergeBaseDiff', { |
| 183 | encoding: 'buffer', |
| 184 | }) |
| 185 | |
| 186 | return buildDiff(result.stdout, repository, file, latestCommit, latestCommit) |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Render the difference between two commits for a file |
no test coverage detected