Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions src/git/remotes/azure-devops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
Expand All @@ -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}`;
Expand All @@ -35,13 +39,21 @@ 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,
// the `path` will be previously encoded during git clone
// 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;
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions src/git/remotes/remoteProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ export abstract class RemoteProvider<T extends ResourceDescriptor = ResourceDesc
return { owner: this.owner, name: this.repoName } as unknown as T;
}

get providerDesc():
| {
id: GkProviderId;
repoDomain: string;
repoName: string;
repoOwnerDomain?: string;
}
| undefined {
if (this.gkProviderId == null || this.owner == null || this.repoName == null) return undefined;

return { id: this.gkProviderId, repoDomain: this.owner, repoName: this.repoName };
}

get repoName(): string | undefined {
return this.splitPath()[1];
}
Expand Down
12 changes: 1 addition & 11 deletions src/plus/drafts/draftsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,7 @@ export class DraftService implements Disposable {
domain: remote.domain,
path: remote.path,
},
provider:
remote.provider.gkProviderId != null &&
remote.provider.owner != null &&
remote.provider.repoName != null
? {
id: remote.provider.gkProviderId,
repoDomain: remote.provider.owner,
repoName: remote.provider.repoName,
// repoOwnerDomain: ??
}
: undefined,
provider: remote.provider.providerDesc,
};
}

Expand Down