Skip to content

Commit

Permalink
Fixes gitkraken#2021 - Use scoped routes for GitLab URLs
Browse files Browse the repository at this point in the history
GitLens uses legacy project routes for GitLab:

- `${projectURL}/branches`
- `${projectURL}/tree/${branch}`
- `${projectURL}/commit/${sha}`
- `${projectURL}/compare/${base}${notation}${compare}`
- `${projectURL}/blob/${ref}/${fileName}`

These routes are all deprecated and scheduled for removal. See these references:

- https://docs.gitlab.com/ee/development/routing.html#project-routes
- https://gitlab.com/gitlab-org/gitlab/-/issues/118849
- https://gitlab.com/gitlab-org/gitlab/-/issues/28848

This change replaces them with the following scoped routes:

- `${projectURL}/-/branches`
- `${projectURL}/-/tree/${branch}`
- `${projectURL}/-/commit/${sha}`
- `${projectURL}/-/compare/${base}${notation}${compare}`
- `${projectURL}/-/blob/${ref}/${fileName}`
  • Loading branch information
Brcrwilliams committed Jun 2, 2022
1 parent b5d7d42 commit 6315e84
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/git/remotes/gitlab.ts
Expand Up @@ -105,15 +105,15 @@ export class GitLabRemote extends RemoteProvider {
}

protected getUrlForBranches(): string {
return this.encodeUrl(`${this.baseUrl}/branches`);
return this.encodeUrl(`${this.baseUrl}/-/branches`);
}

protected getUrlForBranch(branch: string): string {
return this.encodeUrl(`${this.baseUrl}/tree/${branch}`);
return this.encodeUrl(`${this.baseUrl}/-/tree/${branch}`);
}

protected getUrlForCommit(sha: string): string {
return this.encodeUrl(`${this.baseUrl}/commit/${sha}`);
return this.encodeUrl(`${this.baseUrl}/-/commit/${sha}`);
}

protected override getUrlForComparison(base: string, compare: string, notation: '..' | '...'): string {
Expand All @@ -132,8 +132,8 @@ export class GitLabRemote extends RemoteProvider {
line = '';
}

if (sha) return `${this.encodeUrl(`${this.baseUrl}/blob/${sha}/${fileName}`)}${line}`;
if (branch) return `${this.encodeUrl(`${this.baseUrl}/blob/${branch}/${fileName}`)}${line}`;
if (sha) return `${this.encodeUrl(`${this.baseUrl}/-/blob/${sha}/${fileName}`)}${line}`;
if (branch) return `${this.encodeUrl(`${this.baseUrl}/-/blob/${branch}/${fileName}`)}${line}`;
return `${this.encodeUrl(`${this.baseUrl}?path=${fileName}`)}${line}`;
}
}

0 comments on commit 6315e84

Please sign in to comment.