浏览代码

Improves ref names in comparison deeplinks

main
Eric Amodio 1年前
父节点
当前提交
d527da7efa
共有 5 个文件被更改,包括 33 次插入23 次删除
  1. +1
    -0
      CHANGELOG.md
  2. +8
    -8
      src/commands/base.ts
  3. +5
    -4
      src/commands/copyDeepLink.ts
  4. +11
    -11
      src/uris/deepLinks/deepLinkService.ts
  5. +8
    -0
      src/views/nodes/compareResultsNode.ts

+ 1
- 0
CHANGELOG.md 查看文件

@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Changed
- Improves autolink URL generation by improving the "best" remote detection — refs [#2425](https://github.com/gitkraken/vscode-gitlens/issues/2425)
- Improves preserving the ref names in deeplinks to comparisons
### Fixed

+ 8
- 8
src/commands/base.ts 查看文件

@ -9,7 +9,7 @@ import type {
} from 'vscode';
import { commands, Disposable, Uri, window } from 'vscode';
import type { ActionContext } from '../api/gitlens';
import type { Commands } from '../constants';
import type { Commands, StoredNamedRef } from '../constants';
import type { GitBranch } from '../git/models/branch';
import { isBranch } from '../git/models/branch';
import type { GitCommit, GitStashCommit } from '../git/models/commit';
@ -159,16 +159,16 @@ export function isCommandContextViewNodeHasFileRefs(context: CommandContext): co
);
}
export function isCommandContextViewNodeHasComparison(
context: CommandContext,
): context is CommandViewNodeContext & { node: ViewNode & { _ref: { ref: string }; _compareWith: { ref: string } } } {
export function isCommandContextViewNodeHasComparison(context: CommandContext): context is CommandViewNodeContext & {
node: ViewNode & { compareRef: StoredNamedRef; compareWithRef: StoredNamedRef };
} {
if (context.type !== 'viewItem') return false;
return (
typeof (context.node as ViewNode & { _ref: { ref: string }; _compareWith: { ref: string } })._ref?.ref ===
'string' &&
typeof (context.node as ViewNode & { _ref: { ref: string }; _compareWith: { ref: string } })._compareWith
?.ref === 'string'
typeof (context.node as ViewNode & { compareRef: StoredNamedRef; compareWithRef: StoredNamedRef }).compareRef
?.ref === 'string' &&
typeof (context.node as ViewNode & { compareRef: StoredNamedRef; compareWithRef: StoredNamedRef })
.compareWithRef?.ref === 'string'
);
}

+ 5
- 4
src/commands/copyDeepLink.ts 查看文件

@ -1,4 +1,5 @@
import type { TextEditor, Uri } from 'vscode';
import type { StoredNamedRef } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
@ -23,8 +24,8 @@ import {
export interface CopyDeepLinkCommandArgs {
refOrRepoPath?: GitReference | string;
compareRef?: string;
compareWithRef?: string;
compareRef?: StoredNamedRef;
compareWithRef?: StoredNamedRef;
remote?: string;
prePickRemote?: boolean;
}
@ -54,8 +55,8 @@ export class CopyDeepLinkCommand extends ActiveEditorCommand {
} else if (isCommandContextViewNodeHasComparison(context)) {
args = {
refOrRepoPath: context.node.uri.fsPath,
compareRef: context.node._ref.ref,
compareWithRef: context.node._compareWith.ref,
compareRef: context.node.compareRef,
compareWithRef: context.node.compareWithRef,
};
}
}

+ 11
- 11
src/uris/deepLinks/deepLinkService.ts 查看文件

@ -1,5 +1,5 @@
import { Disposable, env, EventEmitter, ProgressLocation, Uri, window, workspace } from 'vscode';
import type { StoredDeepLinkContext } from '../../constants';
import type { StoredDeepLinkContext, StoredNamedRef } from '../../constants';
import { Commands } from '../../constants';
import type { Container } from '../../container';
import { getBranchNameWithoutRemote } from '../../git/models/branch';
@ -691,14 +691,14 @@ export class DeepLinkService implements Disposable {
async copyDeepLinkUrl(
repoPath: string,
remoteUrl: string,
compareRef?: string,
compareWithRef?: string,
compareRef?: StoredNamedRef,
compareWithRef?: StoredNamedRef,
): Promise<void>;
async copyDeepLinkUrl(
refOrRepoPath: string | GitReference,
remoteUrl: string,
compareRef?: string,
compareWithRef?: string,
compareRef?: StoredNamedRef,
compareWithRef?: StoredNamedRef,
): Promise<void> {
const url = await (typeof refOrRepoPath === 'string'
? this.generateDeepLinkUrl(refOrRepoPath, remoteUrl, compareRef, compareWithRef)
@ -710,14 +710,14 @@ export class DeepLinkService implements Disposable {
async generateDeepLinkUrl(
repoPath: string,
remoteUrl: string,
compareRef?: string,
compareWithRef?: string,
compareRef?: StoredNamedRef,
compareWithRef?: StoredNamedRef,
): Promise<URL>;
async generateDeepLinkUrl(
refOrRepoPath: string | GitReference,
remoteUrl: string,
compareRef?: string,
compareWithRef?: string,
compareRef?: StoredNamedRef,
compareWithRef?: StoredNamedRef,
): Promise<URL> {
const repoPath = typeof refOrRepoPath !== 'string' ? refOrRepoPath.repoPath : refOrRepoPath;
let repoId;
@ -751,8 +751,8 @@ export class DeepLinkService implements Disposable {
if (compareRef != null && compareWithRef != null) {
targetType = DeepLinkType.Comparison;
targetId = compareRef;
compareWithTargetId = compareWithRef;
targetId = compareRef.label ?? compareRef.ref;
compareWithTargetId = compareWithRef.label ?? compareWithRef.ref;
}
const schemeOverride = configuration.get('deepLinks.schemeOverride');

+ 8
- 0
src/views/nodes/compareResultsNode.ts 查看文件

@ -60,6 +60,14 @@ export class CompareResultsNode extends ViewNode {
return !this.pinned;
}
get compareRef(): StoredNamedRef {
return this._ref;
}
get compareWithRef(): StoredNamedRef {
return this._compareWith;
}
private readonly _order: number = Date.now();
get order(): number {
return this._pinned || this._order;

正在加载...
取消
保存