Browse Source

Fixes initial patch repo location state on cloud patch open

main
Ramin Tadayon 1 year ago
parent
commit
61b51c750e
No known key found for this signature in database GPG Key ID: 79D60DDE3DFB95F5
2 changed files with 17 additions and 10 deletions
  1. +4
    -1
      src/plus/drafts/draftsService.ts
  2. +13
    -9
      src/plus/repos/repositoryIdentityService.ts

+ 4
- 1
src/plus/drafts/draftsService.ts View File

@ -479,7 +479,10 @@ export class DraftService implements Disposable {
const [contentsResult, repositoryResult] = await Promise.allSettled([
this.getPatchContentsCore(patch.secureLink),
this.container.repositoryIdentity.getRepositoryOrIdentity(patch.gkRepositoryId),
this.container.repositoryIdentity.getRepositoryOrIdentity(patch.gkRepositoryId, {
openIfNeeded: true,
skipRefValidation: true,
}),
]);
const contents = getSettledValue(contentsResult)!;

+ 13
- 9
src/plus/repos/repositoryIdentityService.ts View File

@ -25,17 +25,17 @@ export class RepositoryIdentityService implements Disposable {
getRepository(
id: GkRepositoryId,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | undefined>;
getRepository(
identity: RepositoryIdentity,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | undefined>;
@log()
getRepository(
idOrIdentity: GkRepositoryId | RepositoryIdentity,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | undefined> {
return this.locateRepository(idOrIdentity, options);
}
@ -43,7 +43,7 @@ export class RepositoryIdentityService implements Disposable {
@log()
async getRepositoryOrIdentity(
id: GkRepositoryId,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | RepositoryIdentity> {
const identity = await this.getRepositoryIdentity(id);
return (await this.locateRepository(identity, options)) ?? identity;
@ -51,20 +51,20 @@ export class RepositoryIdentityService implements Disposable {
private async locateRepository(
id: GkRepositoryId,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | undefined>;
private async locateRepository(
identity: RepositoryIdentity,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | undefined>;
private async locateRepository(
idOrIdentity: GkRepositoryId | RepositoryIdentity,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | undefined>;
@log()
private async locateRepository(
idOrIdentity: GkRepositoryId | RepositoryIdentity,
options?: { openIfNeeded?: boolean; prompt?: boolean },
options?: { openIfNeeded?: boolean; prompt?: boolean; skipRefValidation?: boolean },
): Promise<Repository | undefined> {
const identity =
typeof idOrIdentity === 'string' ? await this.getRepositoryIdentity(idOrIdentity) : idOrIdentity;
@ -111,7 +111,11 @@ export class RepositoryIdentityService implements Disposable {
}
}
if (identity.initialCommitSha != null && identity.initialCommitSha !== missingRepositoryId) {
if (
!options?.skipRefValidation &&
identity.initialCommitSha != null &&
identity.initialCommitSha !== missingRepositoryId
) {
// Repo ID can be any valid SHA in the repo, though standard practice is to use the
// first commit SHA.
if (await this.container.git.validateReference(repo.uri, identity.initialCommitSha)) {

Loading…
Cancel
Save