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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Added an optional `webUrl` field to the GitLab connection config, used to build links to repositories in the GitLab web UI when the API host differs from the browsable host. [#1457](https://github.com/sourcebot-dev/sourcebot/pull/1457)

### Fixed
- Prevented focus rings in workspace connector dialogs from being clipped. [#1457](https://github.com/sourcebot-dev/sourcebot/pull/1457)

Expand Down
9 changes: 9 additions & 0 deletions docs/snippets/schemas/v3/connection.schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"webUrl": {
"type": "string",
"format": "url",
"description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.",
"examples": [
"https://gitlab.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"all": {
"type": "boolean",
"default": false,
Expand Down
9 changes: 9 additions & 0 deletions docs/snippets/schemas/v3/gitlab.schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"webUrl": {
"type": "string",
"format": "url",
"description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.",
"examples": [
"https://gitlab.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"all": {
"type": "boolean",
"default": false,
Expand Down
9 changes: 9 additions & 0 deletions docs/snippets/schemas/v3/index.schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,15 @@
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"webUrl": {
"type": "string",
"format": "url",
"description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.",
"examples": [
"https://gitlab.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"all": {
"type": "boolean",
"default": false,
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/repoCompileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ export const compileGitlabConfig = async (
const warnings = gitlabReposResult.warnings;

const hostUrl = (config.url ?? 'https://gitlab.com').replace(/\/+$/, '');
const webUrl = (config.webUrl ?? hostUrl).replace(/\/+$/, '');
const repoNameRoot = new URL(hostUrl)
.toString()
.replace(/^https?:\/\//, '');

const repos = gitlabRepos.map((project) => {
const projectUrl = `${hostUrl}/${project.path_with_namespace}`;
const projectUrl = `${webUrl}/${project.path_with_namespace}`;
Comment thread
brendan-kellam marked this conversation as resolved.
const cloneUrl = new URL(project.http_url_to_repo);
cloneUrl.protocol = new URL(hostUrl).protocol;
const isFork = project.forked_from_project !== undefined;
Expand Down
9 changes: 9 additions & 0 deletions packages/schemas/src/v3/connection.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ const schema = {
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"webUrl": {
"type": "string",
"format": "url",
"description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.",
"examples": [
"https://gitlab.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"all": {
"type": "boolean",
"default": false,
Expand Down
4 changes: 4 additions & 0 deletions packages/schemas/src/v3/connection.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export interface GitlabConnectionConfig {
* The URL of the GitLab host. Defaults to https://gitlab.com
*/
url?: string;
/**
* The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.
*/
webUrl?: string;
/**
* Sync all projects visible to the provided `token` (if any) in the GitLab instance. This option is ignored if `url` is either unset or set to https://gitlab.com .
*/
Expand Down
9 changes: 9 additions & 0 deletions packages/schemas/src/v3/gitlab.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ const schema = {
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"webUrl": {
"type": "string",
"format": "url",
"description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.",
"examples": [
"https://gitlab.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"all": {
"type": "boolean",
"default": false,
Expand Down
4 changes: 4 additions & 0 deletions packages/schemas/src/v3/gitlab.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export interface GitlabConnectionConfig {
* The URL of the GitLab host. Defaults to https://gitlab.com
*/
url?: string;
/**
* The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.
*/
webUrl?: string;
/**
* Sync all projects visible to the provided `token` (if any) in the GitLab instance. This option is ignored if `url` is either unset or set to https://gitlab.com .
*/
Expand Down
9 changes: 9 additions & 0 deletions packages/schemas/src/v3/index.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,15 @@ const schema = {
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"webUrl": {
"type": "string",
"format": "url",
"description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.",
"examples": [
"https://gitlab.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"all": {
"type": "boolean",
"default": false,
Expand Down
4 changes: 4 additions & 0 deletions packages/schemas/src/v3/index.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ export interface GitlabConnectionConfig {
* The URL of the GitLab host. Defaults to https://gitlab.com
*/
url?: string;
/**
* The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.
*/
webUrl?: string;
/**
* Sync all projects visible to the provided `token` (if any) in the GitLab instance. This option is ignored if `url` is either unset or set to https://gitlab.com .
*/
Expand Down
9 changes: 9 additions & 0 deletions schemas/v3/gitlab.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"webUrl": {
"type": "string",
"format": "url",
"description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.",
"examples": [
"https://gitlab.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
Comment thread
brendan-kellam marked this conversation as resolved.
"all": {
"type": "boolean",
"default": false,
Expand Down
Loading