From 87232bce784a60f2571598a21d7861bc7e7ef58a Mon Sep 17 00:00:00 2001 From: nzaytsev Date: Tue, 23 Jul 2024 12:53:55 +0700 Subject: [PATCH] Fixes azure cloud patch creation error GLVSC-570 - Uses remote.provider.owner as repoOwnerDomain - Passes project as remote provider to azure repos --- CHANGELOG.md | 4 ++++ src/git/remotes/azure-devops.ts | 32 +++++++++++++++++++++++++++++++ src/git/remotes/remoteProvider.ts | 13 +++++++++++++ src/plus/drafts/draftsService.ts | 12 +----------- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a4489f25d648..30817ef34b847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Fixed + +- Fixes cloud patch creation error on azure repos + ## [15.2.1] - 2024-07-24 ### Added diff --git a/src/git/remotes/azure-devops.ts b/src/git/remotes/azure-devops.ts index 1346c6c7c5da4..07c654016e6b2 100644 --- a/src/git/remotes/azure-devops.ts +++ b/src/git/remotes/azure-devops.ts @@ -17,7 +17,9 @@ const fileRegex = /path=([^&]+)/i; const rangeRegex = /line=(\d+)(?:&lineEnd=(\d+))?/; export class AzureDevOpsRemote extends RemoteProvider { + private readonly project: string | undefined; constructor(domain: string, path: string, protocol?: string, name?: string, legacy: boolean = false) { + let repoProject; if (sshDomainRegex.test(domain)) { path = path.replace(sshPathRegex, ''); domain = domain.replace(sshDomainRegex, ''); @@ -27,6 +29,8 @@ export class AzureDevOpsRemote extends RemoteProvider { if (match != null) { const [, org, project, rest] = match; + repoProject = project; + // Handle legacy vsts urls if (legacy) { domain = `${org}.${domain}`; @@ -35,6 +39,13 @@ export class AzureDevOpsRemote extends RemoteProvider { path = `${org}/${project}/_git/${rest}`; } } + } else { + const match = orgAndProjectRegex.exec(path); + if (match != null) { + const [, , project] = match; + + repoProject = project; + } } // Azure DevOps allows projects and repository names with spaces. In that situation, @@ -42,6 +53,7 @@ export class AzureDevOpsRemote extends RemoteProvider { // revert that encoding to avoid double-encoding by gitlens during copy remote and open remote path = decodeURIComponent(path); super(domain, path, protocol, name); + this.project = repoProject; } private _autolinks: (AutolinkReference | DynamicAutolinkReference)[] | undefined; @@ -88,6 +100,26 @@ export class AzureDevOpsRemote extends RemoteProvider { return 'Azure DevOps'; } + override get providerDesc(): + | { + id: GkProviderId; + repoDomain: string; + repoName: string; + repoOwnerDomain: string; + } + | undefined { + if (this.gkProviderId == null || this.owner == null || this.repoName == null || this.project == null) { + return undefined; + } + + return { + id: this.gkProviderId, + repoDomain: this.project, + repoName: this.repoName, + repoOwnerDomain: this.owner, + }; + } + private _displayPath: string | undefined; override get displayPath(): string { if (this._displayPath === undefined) { diff --git a/src/git/remotes/remoteProvider.ts b/src/git/remotes/remoteProvider.ts index 0e2311cae2796..d1bbec88a7d32 100644 --- a/src/git/remotes/remoteProvider.ts +++ b/src/git/remotes/remoteProvider.ts @@ -66,6 +66,19 @@ export abstract class RemoteProvider