Skip to content

Commit

Permalink
#274 Fixed the files shown in the Commit Details View for merge commits.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhutchie committed Mar 5, 2020
1 parent dbf87cb commit d749db5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,15 @@ export class DataSource implements vscode.Disposable {
* Get the commit details for the Commit Details View.
* @param repo The path of the repository.
* @param commitHash The hash of the commit open in the Commit Details View.
* @param hasParents Does the commit have parents
* @returns The commit details.
*/
public getCommitDetails(repo: string, commitHash: string): Promise<GitCommitDetailsData> {
public getCommitDetails(repo: string, commitHash: string, hasParents: boolean): Promise<GitCommitDetailsData> {
const fromCommit = commitHash + (hasParents ? '^' : '');
return Promise.all([
this.getCommitDetailsBase(repo, commitHash),
this.getDiffNameStatus(repo, commitHash, commitHash),
this.getDiffNumStat(repo, commitHash, commitHash)
this.getDiffNameStatus(repo, fromCommit, commitHash),
this.getDiffNumStat(repo, fromCommit, commitHash)
]).then((results) => {
results[0].fileChanges = generateFileChanges(results[1], results[2], null);
return { commitDetails: results[0], error: null };
Expand Down Expand Up @@ -1352,9 +1354,9 @@ export class DataSource implements vscode.Disposable {
private execDiff(repo: string, fromHash: string, toHash: string, arg: '--numstat' | '--name-status') {
let args: string[];
if (fromHash === toHash) {
args = ['diff-tree', arg, '-r', '-m', '--root', '--find-renames', '--diff-filter=AMDR', '-z', fromHash];
args = ['diff-tree', arg, '-r', '--root', '--find-renames', '--diff-filter=AMDR', '-z', fromHash];
} else {
args = ['diff', arg, '-m', '--find-renames', '--diff-filter=AMDR', '-z', fromHash];
args = ['diff', arg, '--find-renames', '--diff-filter=AMDR', '-z', fromHash];
if (toHash !== '') args.push(toHash);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class GitGraphView implements vscode.Disposable {
msg.commitHash === UNCOMMITTED
? this.dataSource.getUncommittedDetails(msg.repo)
: msg.stash === null
? this.dataSource.getCommitDetails(msg.repo, msg.commitHash)
? this.dataSource.getCommitDetails(msg.repo, msg.commitHash, msg.hasParents)
: this.dataSource.getStashDetails(msg.repo, msg.commitHash, msg.stash),
msg.avatarEmail !== null ? this.avatarManager.getAvatarImage(msg.avatarEmail) : Promise.resolve(null)
]);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ export interface RequestCodeReviewFileReviewed extends RepoRequest {
export interface RequestCommitDetails extends RepoRequest {
readonly command: 'commitDetails';
readonly commitHash: string;
readonly hasParents: boolean;
readonly stash: GitCommitStash | null; // null => request is for a commit, otherwise => request is for a stash
readonly avatarEmail: string | null; // string => fetch avatar with the given email, null => don't fetch avatar
readonly refresh: boolean;
Expand Down
1 change: 1 addition & 0 deletions web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ class GitGraphView {
command: 'commitDetails',
repo: this.currentRepo,
commitHash: hash,
hasParents: commit.parents.length > 0,
stash: commit.stash,
avatarEmail: this.config.fetchAvatars && hash !== UNCOMMITTED ? commit.email : null,
refresh: refresh
Expand Down

0 comments on commit d749db5

Please sign in to comment.