Parcourir la source

Removes repo location from patch deep link flow

main
Ramin Tadayon il y a 1 an
Parent
révision
bce414173e
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 79D60DDE3DFB95F5
3 fichiers modifiés avec 9 ajouts et 73 suppressions
  1. +4
    -1
      src/plus/webviews/patchDetails/patchDetailsWebview.ts
  2. +1
    -8
      src/uris/deepLinks/deepLink.ts
  3. +4
    -64
      src/uris/deepLinks/deepLinkService.ts

+ 4
- 1
src/plus/webviews/patchDetails/patchDetailsWebview.ts Voir le fichier

@ -821,7 +821,10 @@ export class PatchDetailsWebviewProvider
openIfNeeded: true,
prompt: true,
});
if (repo == null) return undefined; // TODO
if (repo == null) {
void window.showErrorMessage(`Unable to locate repository '${patch.repository.name}'`);
return undefined;
}
patch.repository = repo;
}

+ 1
- 8
src/uris/deepLinks/deepLink.ts Voir le fichier

@ -2,7 +2,6 @@ import type { Uri } from 'vscode';
import type { GitReference } from '../../git/models/reference';
import type { GitRemote } from '../../git/models/remote';
import type { Repository } from '../../git/models/repository';
import type { Draft } from '../../gk/models/drafts';
export type UriTypes = 'link';
@ -183,11 +182,9 @@ export const enum DeepLinkServiceAction {
PlanCheckPassed,
RepoMatched,
RepoMatchedInLocalMapping,
RepoMatchedForDraft,
RepoMatchFailed,
RepoAdded,
RepoOpened,
RepoOpenedForDraft,
RemoteMatched,
RemoteMatchFailed,
RemoteMatchUnneeded,
@ -215,7 +212,6 @@ export interface DeepLinkServiceContext {
targetType?: DeepLinkType | undefined;
targetSha?: string | undefined;
secondaryTargetSha?: string | undefined;
targetDraft?: Draft | undefined;
}
export const deepLinkStateTransitionTable: Record<string, Record<string, DeepLinkServiceState>> = {
@ -237,7 +233,7 @@ export const deepLinkStateTransitionTable: Record
[DeepLinkServiceAction.DeepLinkErrored]: DeepLinkServiceState.Idle,
[DeepLinkServiceAction.DeepLinkCancelled]: DeepLinkServiceState.Idle,
[DeepLinkServiceAction.LinkIsRepoType]: DeepLinkServiceState.RepoMatch,
[DeepLinkServiceAction.LinkIsDraftType]: DeepLinkServiceState.RepoMatch,
[DeepLinkServiceAction.LinkIsDraftType]: DeepLinkServiceState.OpenDraft,
[DeepLinkServiceAction.LinkIsWorkspaceType]: DeepLinkServiceState.OpenWorkspace,
},
[DeepLinkServiceState.RepoMatch]: {
@ -245,19 +241,16 @@ export const deepLinkStateTransitionTable: Record
[DeepLinkServiceAction.RepoMatched]: DeepLinkServiceState.RemoteMatch,
[DeepLinkServiceAction.RepoMatchedInLocalMapping]: DeepLinkServiceState.CloneOrAddRepo,
[DeepLinkServiceAction.RepoMatchFailed]: DeepLinkServiceState.CloneOrAddRepo,
[DeepLinkServiceAction.RepoMatchedForDraft]: DeepLinkServiceState.OpenDraft,
},
[DeepLinkServiceState.CloneOrAddRepo]: {
[DeepLinkServiceAction.OpenRepo]: DeepLinkServiceState.OpeningRepo,
[DeepLinkServiceAction.RepoOpened]: DeepLinkServiceState.RemoteMatch,
[DeepLinkServiceAction.RepoOpenedForDraft]: DeepLinkServiceState.OpenDraft,
[DeepLinkServiceAction.DeepLinkErrored]: DeepLinkServiceState.Idle,
[DeepLinkServiceAction.DeepLinkCancelled]: DeepLinkServiceState.Idle,
[DeepLinkServiceAction.DeepLinkStored]: DeepLinkServiceState.Idle,
},
[DeepLinkServiceState.OpeningRepo]: {
[DeepLinkServiceAction.RepoAdded]: DeepLinkServiceState.AddedRepoMatch,
[DeepLinkServiceAction.RepoOpenedForDraft]: DeepLinkServiceState.OpenDraft,
[DeepLinkServiceAction.DeepLinkErrored]: DeepLinkServiceState.Idle,
[DeepLinkServiceAction.DeepLinkCancelled]: DeepLinkServiceState.Idle,
},

+ 4
- 64
src/uris/deepLinks/deepLinkService.ts Voir le fichier

@ -108,7 +108,6 @@ export class DeepLinkService implements Disposable {
secondaryRemoteUrl: undefined,
targetType: undefined,
targetSha: undefined,
targetDraft: undefined,
};
}
@ -147,10 +146,7 @@ export class DeepLinkService implements Disposable {
const repo = await this.container.git.getOrOpenRepository(repoOpenUri, { detectNested: false });
if (repo != null) {
this._context.repo = repo;
action =
this._context.targetType === DeepLinkType.Draft
? DeepLinkServiceAction.RepoOpenedForDraft
: DeepLinkServiceAction.RepoOpened;
action = DeepLinkServiceAction.RepoOpened;
}
} catch {}
}
@ -500,49 +496,13 @@ export class DeepLinkService implements Disposable {
}
case DeepLinkServiceState.RepoMatch:
case DeepLinkServiceState.AddedRepoMatch: {
if (!mainId && !remoteUrl && !repoPath && targetType !== DeepLinkType.Draft) {
if (!mainId && !remoteUrl && !repoPath) {
action = DeepLinkServiceAction.DeepLinkErrored;
message = 'No repository id, remote url or path was provided.';
break;
}
let repoIdentity: RepositoryIdentity | undefined;
let draftRepo: Repository | undefined;
if (targetType === DeepLinkType.Draft) {
if (this._context.targetDraft == null && targetId != null) {
try {
this._context.targetDraft = await this.container.drafts.getDraft(targetId);
} catch (ex) {
action = DeepLinkServiceAction.DeepLinkErrored;
message = `Unable to fetch draft${ex.message ? ` - ${ex.message}` : ''}`;
break;
}
}
if (
this._context.targetDraft?.changesets?.length &&
this._context.targetDraft?.changesets[0].patches?.length
) {
// TODO@axosoft-ramint Look at this
// draftRepoData = this._context.targetDraft.changesets[0].patches[0].repoData;
const repoOrIdentity = this._context.targetDraft.changesets[0].patches[0].repository;
if (isRepository(repoOrIdentity)) {
draftRepo = repoOrIdentity;
if (draftRepo == null) {
const gkId = this._context.targetDraft.changesets[0].patches[0].gkRepositoryId;
draftRepo = await this.container.repositoryIdentity.getRepository(gkId);
}
} else {
repoIdentity = repoOrIdentity;
}
}
}
if (draftRepo != null && targetType === DeepLinkType.Draft) {
action = DeepLinkServiceAction.RepoMatchedForDraft;
break;
}
let mainIdToSearch = mainId;
let remoteUrlToSearch = remoteUrl;
@ -618,14 +578,6 @@ export class DeepLinkService implements Disposable {
}
}
if (targetType === DeepLinkType.Draft && this._context.repo != null) {
action = DeepLinkServiceAction.RepoMatchedForDraft;
if (this._context.targetDraft?.changesets?.[0]?.patches?.[0] != null) {
this._context.targetDraft.changesets[0].patches[0].repository = this._context.repo;
}
break;
}
if (!this._context.repo) {
if (state === DeepLinkServiceState.RepoMatch) {
action = DeepLinkServiceAction.RepoMatchFailed;
@ -638,7 +590,7 @@ export class DeepLinkService implements Disposable {
break;
}
case DeepLinkServiceState.CloneOrAddRepo: {
if (!mainId && !remoteUrl && !repoPath && targetType !== DeepLinkType.Draft) {
if (!mainId && !remoteUrl && !repoPath) {
action = DeepLinkServiceAction.DeepLinkErrored;
message = 'Missing repository id, remote url and path.';
break;
@ -672,11 +624,6 @@ export class DeepLinkService implements Disposable {
});
}
if (repoOpenType === 'current' && targetType === DeepLinkType.Draft) {
action = DeepLinkServiceAction.RepoOpenedForDraft;
break;
}
if (!repoOpenType) {
action = DeepLinkServiceAction.DeepLinkCancelled;
break;
@ -771,13 +718,7 @@ export class DeepLinkService implements Disposable {
case DeepLinkServiceState.OpeningRepo: {
this._disposables.push(
once(this.container.git.onDidChangeRepositories)(() => {
queueMicrotask(() =>
this.processDeepLink(
targetType === DeepLinkType.Draft
? DeepLinkServiceAction.RepoOpenedForDraft
: DeepLinkServiceAction.RepoAdded,
),
);
queueMicrotask(() => this.processDeepLink(DeepLinkServiceAction.RepoAdded));
}),
);
return;
@ -1025,7 +966,6 @@ export class DeepLinkService implements Disposable {
void (await executeCommand(Commands.OpenCloudPatch, {
id: targetId,
patchId: secondaryTargetId,
draft: this._context.targetDraft,
}));
action = DeepLinkServiceAction.DeepLinkResolved;
break;

Chargement…
Annuler
Enregistrer