Skip to content

Commit fd5d57f

Browse files
committed
Reverses deeplink comparision ordering
1 parent f1d2fa4 commit fd5d57f

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1717
### Fixed
1818

1919
- Fixes [#2744](https://github.com/gitkraken/vscode-gitlens/issues/2744) - GH enterprise access with focus view
20+
- Fixes deeplink comparison ordering for a better experience
2021

2122
## [14.1.0] - 2023-07-13
2223

src/uris/deepLinks/deepLinkService.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Commands } from '../../constants';
44
import type { Container } from '../../container';
55
import { getBranchNameWithoutRemote } from '../../git/models/branch';
66
import type { GitReference } from '../../git/models/reference';
7-
import { createReference } from '../../git/models/reference';
7+
import { createReference, isSha } from '../../git/models/reference';
88
import type { GitRemote } from '../../git/models/remote';
99
import { parseGitRemoteUrl } from '../../git/parsers/remoteParser';
1010
import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol';
@@ -669,7 +669,13 @@ export class DeepLinkService implements Disposable {
669669
break;
670670
}
671671

672-
await this.container.searchAndCompareView.compare(repo.path, targetSha, secondaryTargetSha);
672+
await this.container.searchAndCompareView.compare(
673+
repo.path,
674+
isSha(secondaryTargetSha)
675+
? secondaryTargetSha
676+
: { label: secondaryTargetSha, ref: secondaryTargetSha },
677+
isSha(targetSha) ? targetSha : { label: targetSha, ref: targetSha },
678+
);
673679
action = DeepLinkServiceAction.DeepLinkResolved;
674680
break;
675681

@@ -686,16 +692,16 @@ export class DeepLinkService implements Disposable {
686692
repoPath: string,
687693
remoteUrl: string,
688694
compareRef?: string,
689-
compareToRef?: string,
695+
compareWithRef?: string,
690696
): Promise<void>;
691697
async copyDeepLinkUrl(
692698
refOrRepoPath: string | GitReference,
693699
remoteUrl: string,
694700
compareRef?: string,
695-
compareToRef?: string,
701+
compareWithRef?: string,
696702
): Promise<void> {
697703
const url = await (typeof refOrRepoPath === 'string'
698-
? this.generateDeepLinkUrl(refOrRepoPath, remoteUrl, compareRef, compareToRef)
704+
? this.generateDeepLinkUrl(refOrRepoPath, remoteUrl, compareRef, compareWithRef)
699705
: this.generateDeepLinkUrl(refOrRepoPath, remoteUrl));
700706
await env.clipboard.writeText(url.toString());
701707
}
@@ -705,13 +711,13 @@ export class DeepLinkService implements Disposable {
705711
repoPath: string,
706712
remoteUrl: string,
707713
compareRef?: string,
708-
compareToRef?: string,
714+
compareWithRef?: string,
709715
): Promise<URL>;
710716
async generateDeepLinkUrl(
711717
refOrRepoPath: string | GitReference,
712718
remoteUrl: string,
713719
compareRef?: string,
714-
compareToRef?: string,
720+
compareWithRef?: string,
715721
): Promise<URL> {
716722
const repoPath = typeof refOrRepoPath !== 'string' ? refOrRepoPath.repoPath : refOrRepoPath;
717723
let repoId;
@@ -723,7 +729,7 @@ export class DeepLinkService implements Disposable {
723729

724730
let targetType: DeepLinkType | undefined;
725731
let targetId: string | undefined;
726-
let compareTargetId: string | undefined;
732+
let compareWithTargetId: string | undefined;
727733
if (typeof refOrRepoPath !== 'string') {
728734
switch (refOrRepoPath.refType) {
729735
case 'branch':
@@ -743,17 +749,17 @@ export class DeepLinkService implements Disposable {
743749
}
744750
}
745751

746-
if (compareRef != null && compareToRef != null) {
752+
if (compareRef != null && compareWithRef != null) {
747753
targetType = DeepLinkType.Comparison;
748754
targetId = compareRef;
749-
compareTargetId = compareToRef;
755+
compareWithTargetId = compareWithRef;
750756
}
751757

752758
const schemeOverride = configuration.get('deepLinks.schemeOverride');
753759
const scheme = !schemeOverride ? 'vscode' : schemeOverride === true ? env.uriScheme : schemeOverride;
754760
let target;
755761
if (targetType === DeepLinkType.Comparison) {
756-
target = `/${targetType}/${targetId}...${compareTargetId}`;
762+
target = `/${targetType}/${compareWithTargetId}...${targetId}`;
757763
} else if (targetType != null && targetType !== DeepLinkType.Repository) {
758764
target = `/${targetType}/${targetId}`;
759765
} else {

0 commit comments

Comments
 (0)