Skip to content

Commit 1c447ab

Browse files
committed
Merge upstream/pr-488-dan1994: Resolve conflicts and fix lint
2 parents 8b3772c + 6d93361 commit 1c447ab

10 files changed

Lines changed: 293 additions & 69 deletions

File tree

src/dataSource.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,11 @@ export class DataSource extends Disposable {
355355
* @param repo The path of the repository.
356356
* @param commitHash The hash of the commit open in the Commit Details View.
357357
* @param hasParents Does the commit have parents
358+
* @param parentIndex The index of the commit parent
358359
* @returns The commit details.
359360
*/
360-
public getCommitDetails(repo: string, commitHash: string, hasParents: boolean): Promise<GitCommitDetailsData> {
361-
const fromCommit = commitHash + (hasParents ? '^' : '');
361+
public getCommitDetails(repo: string, commitHash: string, hasParents: boolean, parentIndex: number): Promise<GitCommitDetailsData> {
362+
const fromCommit = commitHash + (hasParents ? '^' + parentIndex : '');
362363
return Promise.all([
363364
this.getCommitDetailsBase(repo, commitHash),
364365
this.getDiffNameStatus(repo, fromCommit, commitHash),
@@ -376,13 +377,15 @@ export class DataSource extends Disposable {
376377
* @param repo The path of the repository.
377378
* @param commitHash The hash of the stash commit open in the Commit Details View.
378379
* @param stash The stash.
380+
* @param parentIndex the index of the stash parent
379381
* @returns The stash details.
380382
*/
381-
public getStashDetails(repo: string, commitHash: string, stash: GitCommitStash): Promise<GitCommitDetailsData> {
383+
public getStashDetails(repo: string, commitHash: string, stash: GitCommitStash, parentIndex: number): Promise<GitCommitDetailsData> {
384+
const fromCommit = commitHash + '^' + parentIndex;
382385
return Promise.all([
383386
this.getCommitDetailsBase(repo, commitHash),
384-
this.getDiffNameStatus(repo, stash.baseHash, commitHash),
385-
this.getDiffNumStat(repo, stash.baseHash, commitHash),
387+
this.getDiffNameStatus(repo, fromCommit, commitHash),
388+
this.getDiffNumStat(repo, fromCommit, commitHash),
386389
stash.untrackedFilesHash !== null ? this.getDiffNameStatus(repo, stash.untrackedFilesHash, stash.untrackedFilesHash) : Promise.resolve([]),
387390
stash.untrackedFilesHash !== null ? this.getDiffNumStat(repo, stash.untrackedFilesHash, stash.untrackedFilesHash) : Promise.resolve([])
388391
]).then((results) => {

src/gitGraphView.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,15 @@ export class GitGraphView extends Disposable {
254254
msg.commitHash === UNCOMMITTED
255255
? this.dataSource.getUncommittedDetails(msg.repo)
256256
: msg.stash === null
257-
? this.dataSource.getCommitDetails(msg.repo, msg.commitHash, msg.hasParents)
258-
: this.dataSource.getStashDetails(msg.repo, msg.commitHash, msg.stash),
257+
? this.dataSource.getCommitDetails(msg.repo, msg.commitHash, msg.hasParents, msg.parentIndex)
258+
: this.dataSource.getStashDetails(msg.repo, msg.commitHash, msg.stash, msg.parentIndex),
259259
msg.avatarEmail !== null ? this.avatarManager.getAvatarImage(msg.avatarEmail) : Promise.resolve(null),
260260
this.cicdManager.getCICDDetail(msg.repo, msg.commitHash)
261261
]);
262262
this.sendMessage({
263263
command: 'commitDetails',
264264
...data[0],
265+
parentIndex: msg.parentIndex,
265266
avatar: data[1],
266267
codeReview: msg.commitHash !== UNCOMMITTED ? this.extensionState.getCodeReview(msg.repo, msg.commitHash) : null,
267268
refresh: msg.refresh,

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,15 @@ export interface RequestCommitDetails extends RepoRequest {
739739
readonly command: 'commitDetails';
740740
readonly commitHash: string;
741741
readonly hasParents: boolean;
742+
readonly parentIndex: number;
742743
readonly stash: GitCommitStash | null; // null => request is for a commit, otherwise => request is for a stash
743744
readonly avatarEmail: string | null; // string => fetch avatar with the given email, null => don't fetch avatar
744745
readonly refresh: boolean;
745746
}
746747
export interface ResponseCommitDetails extends ResponseWithErrorInfo {
747748
readonly command: 'commitDetails';
748749
readonly commitDetails: GitCommitDetails | null;
750+
readonly parentIndex: number;
749751
readonly avatar: string | null;
750752
readonly codeReview: CodeReview | null;
751753
readonly refresh: boolean;

tests/cicdManager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3286,7 +3286,7 @@ describe('CicdManager', () => {
32863286
expect(data).toStrictEqual(null);
32873287
expect(spyOnLog).toHaveBeenNthCalledWith(1, 'Requesting CICD for https://jenkins.net/job/job01/job/MultiBranch/job/master/3/api/json?tree=builds[id,timestamp,fullDisplayName,result,url,actions[lastBuiltRevision[branch[*]]]] page=-1 from Jenkins');
32883288
expect(spyOnLog).toHaveBeenNthCalledWith(2, 'Jenkins API - (200)https://jenkins.net/job/job01/job/MultiBranch/job/master/3/api/json?tree=builds[id,timestamp,fullDisplayName,result,url,actions[lastBuiltRevision[branch[*]]]]');
3289-
expect(spyOnLog).toHaveBeenNthCalledWith(3, 'Jenkins API Error - (200)API Result error. : Unexpected token \'N\', "Not JSON format" is not valid JSON');
3289+
expect(spyOnLog).toHaveBeenNthCalledWith(3, 'Jenkins API Error - (200)API Result error. : Unexpected token \'N\', "Not JSON format" is not valid JSON');
32903290
expect(spyOnLog).toHaveBeenCalledTimes(3);
32913291
});
32923292

0 commit comments

Comments
 (0)