Skip to content

Commit b497760

Browse files
nzaytseveamodio
authored andcommitted
Fixes azure cloud patch creation error GLVSC-570 (#3372)
- Uses remote.provider.owner as repoOwnerDomain - Passes project as remote provider to azure repos
1 parent ab8e33a commit b497760

File tree

4 files changed

+50
-11
lines changed

4 files changed

+50
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Fixes cloud patch creation error on azure repos
12+
913
## [15.2.1] - 2024-07-24
1014

1115
### Added

src/git/remotes/azure-devops.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const fileRegex = /path=([^&]+)/i;
1717
const rangeRegex = /line=(\d+)(?:&lineEnd=(\d+))?/;
1818

1919
export class AzureDevOpsRemote extends RemoteProvider {
20+
private readonly project: string | undefined;
2021
constructor(domain: string, path: string, protocol?: string, name?: string, legacy: boolean = false) {
22+
let repoProject;
2123
if (sshDomainRegex.test(domain)) {
2224
path = path.replace(sshPathRegex, '');
2325
domain = domain.replace(sshDomainRegex, '');
@@ -27,6 +29,8 @@ export class AzureDevOpsRemote extends RemoteProvider {
2729
if (match != null) {
2830
const [, org, project, rest] = match;
2931

32+
repoProject = project;
33+
3034
// Handle legacy vsts urls
3135
if (legacy) {
3236
domain = `${org}.${domain}`;
@@ -35,13 +39,21 @@ export class AzureDevOpsRemote extends RemoteProvider {
3539
path = `${org}/${project}/_git/${rest}`;
3640
}
3741
}
42+
} else {
43+
const match = orgAndProjectRegex.exec(path);
44+
if (match != null) {
45+
const [, , project] = match;
46+
47+
repoProject = project;
48+
}
3849
}
3950

4051
// Azure DevOps allows projects and repository names with spaces. In that situation,
4152
// the `path` will be previously encoded during git clone
4253
// revert that encoding to avoid double-encoding by gitlens during copy remote and open remote
4354
path = decodeURIComponent(path);
4455
super(domain, path, protocol, name);
56+
this.project = repoProject;
4557
}
4658

4759
private _autolinks: (AutolinkReference | DynamicAutolinkReference)[] | undefined;
@@ -88,6 +100,26 @@ export class AzureDevOpsRemote extends RemoteProvider {
88100
return 'Azure DevOps';
89101
}
90102

103+
override get providerDesc():
104+
| {
105+
id: GkProviderId;
106+
repoDomain: string;
107+
repoName: string;
108+
repoOwnerDomain: string;
109+
}
110+
| undefined {
111+
if (this.gkProviderId == null || this.owner == null || this.repoName == null || this.project == null) {
112+
return undefined;
113+
}
114+
115+
return {
116+
id: this.gkProviderId,
117+
repoDomain: this.project,
118+
repoName: this.repoName,
119+
repoOwnerDomain: this.owner,
120+
};
121+
}
122+
91123
private _displayPath: string | undefined;
92124
override get displayPath(): string {
93125
if (this._displayPath === undefined) {

src/git/remotes/remoteProvider.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ export abstract class RemoteProvider<T extends ResourceDescriptor = ResourceDesc
6666
return { owner: this.owner, name: this.repoName } as unknown as T;
6767
}
6868

69+
get providerDesc():
70+
| {
71+
id: GkProviderId;
72+
repoDomain: string;
73+
repoName: string;
74+
repoOwnerDomain?: string;
75+
}
76+
| undefined {
77+
if (this.gkProviderId == null || this.owner == null || this.repoName == null) return undefined;
78+
79+
return { id: this.gkProviderId, repoDomain: this.owner, repoName: this.repoName };
80+
}
81+
6982
get repoName(): string | undefined {
7083
return this.splitPath()[1];
7184
}

src/plus/drafts/draftsService.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,7 @@ export class DraftService implements Disposable {
285285
domain: remote.domain,
286286
path: remote.path,
287287
},
288-
provider:
289-
remote.provider.gkProviderId != null &&
290-
remote.provider.owner != null &&
291-
remote.provider.repoName != null
292-
? {
293-
id: remote.provider.gkProviderId,
294-
repoDomain: remote.provider.owner,
295-
repoName: remote.provider.repoName,
296-
// repoOwnerDomain: ??
297-
}
298-
: undefined,
288+
provider: remote.provider.providerDesc,
299289
};
300290
}
301291

0 commit comments

Comments
 (0)