diff --git a/CHANGELOG.md b/CHANGELOG.md index dda43a0..67964e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ ATTENTION! To support multi-root workspaces some underlying fundamentals had to - Adds `Rebase Branch to Remote (via Terminal)` command (`gitlens.terminalRebaseBranchToRemote`) to branch node(s) of the `GitLens` custom view - Adds `Rebase Commit (via Terminal)` command (`gitlens.terminalRebaseCommit`) to commit node(s) of the `GitLens` custom view - Adds `Reset Commit (via Terminal)` command (`gitlens.terminalResetCommit`) to commit node(s) of the `GitLens` custom view +- Adds ability to specify the url protocol used with user-defined remote services via `gitlens.remotes` setting -- thanks to [PR #192](https://github.com/eamodio/vscode-gitlens/pull/192) by Helmut Januschka ([@hjanuschka](https://github.com/hjanuschka))! ### Changed - `GitLens` custom view will no longer show if there is no Git repository -- closes [#159](https://github.com/eamodio/vscode-gitlens/issues/159) diff --git a/README.md b/README.md index aac30ab..51d4b11 100644 --- a/README.md +++ b/README.md @@ -398,7 +398,7 @@ GitLens is highly customizable and provides many configuration settings to allow |Name | Description |-----|------------ -|`gitlens.remotes`|Specifies user-defined remote (code-hosting) services or custom domains for built-in remote services

Example:
```"gitlens.remotes": [{ "domain": "git.corporate-url.com", "type": "GitHub" }]```

Example:
```"gitlens.remotes": [{ "domain": "git.corporate-url.com", "type": "Custom", "name": "My Company", "urls": { "repository": "https://git.corporate-url.com/${repo}", "branches": "https://git.corporate-url.com/${repo}/branches", "branch": "https://git.corporate-url.com/${repo}/commits/${branch}", "commit": "https://git.corporate-url.com/${repo}/commit/${id}", "file": "https://git.corporate-url.com/${repo}?path=${file}${line}", "fileInBranch": "https://git.corporate-url.com/${repo}/blob/${branch}/${file}${line}", "fileInCommit": "https://git.corporate-url.com/${repo}/blob/${id}/${file}${line}", "fileLine": "#L${line}", "fileRange": "#L${start}-L${end}" } }``` +|`gitlens.remotes`|Specifies user-defined remote (code-hosting) services or custom domains for built-in remote services

Example:
```"gitlens.remotes": [{ "domain": "git.corporate-url.com", "type": "GitHub" }]```

Example:
```"gitlens.remotes": [{ "domain": "git.corporate-url.com", "type": "Custom", "name": "My Company", "protocol": "https", "urls": { "repository": "https://git.corporate-url.com/${repo}", "branches": "https://git.corporate-url.com/${repo}/branches", "branch": "https://git.corporate-url.com/${repo}/commits/${branch}", "commit": "https://git.corporate-url.com/${repo}/commit/${id}", "file": "https://git.corporate-url.com/${repo}?path=${file}${line}", "fileInBranch": "https://git.corporate-url.com/${repo}/blob/${branch}/${file}${line}", "fileInCommit": "https://git.corporate-url.com/${repo}/blob/${id}/${file}${line}", "fileLine": "#L${line}", "fileRange": "#L${start}-L${end}" } }``` ### Status Bar Settings @@ -459,6 +459,7 @@ GitLens is highly customizable and provides many configuration settings to allow A big thanks to the people that have contributed to this project: - Amanda Cameron ([@AmandaCameron](https://github.com/AmandaCameron)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=AmandaCameron)) +- Helmut Januschka ([@hjanuschka](https://github.com/hjanuschka)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=hjanuschka)) - Chris Kaczor ([@ckaczor](https://github.com/ckaczor)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=ckaczor)) - Peng Lyu ([@rebornix](https://github.com/rebornix)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=rebornix)) - Aurelio Ogliari ([@nobitagit](https://github.com/nobitagit)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=nobitagit) diff --git a/package.json b/package.json index 43d0003..d4bc700 100644 --- a/package.json +++ b/package.json @@ -575,6 +575,11 @@ "type": "string", "description": "Specifies an optional friendly name for the custom remote service" }, + "protocol": { + "type": "string", + "default": "https", + "description": "Specifies an optional url protocol for the custom remote service" + }, "urls": { "type": "object", "required": [ diff --git a/src/configuration.ts b/src/configuration.ts index f30ba71..59404cc 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -143,6 +143,7 @@ export interface IRemotesConfig { type: CustomRemoteType; domain: string; name?: string; + protocol?: string; urls?: IRemotesUrlsConfig; } diff --git a/src/git/remotes/bitbucket-server.ts b/src/git/remotes/bitbucket-server.ts index 8fd8e82..3e09ad5 100644 --- a/src/git/remotes/bitbucket-server.ts +++ b/src/git/remotes/bitbucket-server.ts @@ -7,10 +7,11 @@ export class BitbucketServerService extends RemoteProvider { constructor( domain: string, path: string, + protocol?: string, name?: string, custom: boolean = false ) { - super(domain, path, name, custom); + super(domain, path, protocol, name, custom); } get name() { diff --git a/src/git/remotes/bitbucket.ts b/src/git/remotes/bitbucket.ts index 0cc11dd..1e863b7 100644 --- a/src/git/remotes/bitbucket.ts +++ b/src/git/remotes/bitbucket.ts @@ -7,10 +7,11 @@ export class BitbucketService extends RemoteProvider { constructor( domain: string, path: string, + protocol?: string, name?: string, custom: boolean = false ) { - super(domain, path, name, custom); + super(domain, path, protocol, name, custom); } get name() { diff --git a/src/git/remotes/custom.ts b/src/git/remotes/custom.ts index 662a7d1..59f0f11 100644 --- a/src/git/remotes/custom.ts +++ b/src/git/remotes/custom.ts @@ -1,7 +1,7 @@ 'use strict'; import { Strings } from '../../system'; import { Range } from 'vscode'; -import { IRemotesConfig, IRemotesUrlsConfig } from '../../configuration'; +import { IRemotesUrlsConfig } from '../../configuration'; import { RemoteProvider } from './provider'; export class CustomService extends RemoteProvider { @@ -11,10 +11,12 @@ export class CustomService extends RemoteProvider { constructor( domain: string, path: string, - config: IRemotesConfig + urls: IRemotesUrlsConfig, + protocol?: string, + name?: string ) { - super(domain, path, config.name, true); - this.urls = config.urls!; + super(domain, path, protocol, name, true); + this.urls = urls; } get name() { diff --git a/src/git/remotes/factory.ts b/src/git/remotes/factory.ts index 9595212..58e13a0 100644 --- a/src/git/remotes/factory.ts +++ b/src/git/remotes/factory.ts @@ -59,11 +59,11 @@ export class RemoteProviderFactory { private static getCustomProvider(cfg: IRemotesConfig) { switch (cfg.type) { - case CustomRemoteType.Bitbucket: return (domain: string, path: string) => new BitbucketService(domain, path, cfg.name, true); - case CustomRemoteType.BitbucketServer: return (domain: string, path: string) => new BitbucketServerService(domain, path, cfg.name, true); - case CustomRemoteType.Custom: return (domain: string, path: string) => new CustomService(domain, path, cfg); - case CustomRemoteType.GitHub: return (domain: string, path: string) => new GitHubService(domain, path, cfg.name, true); - case CustomRemoteType.GitLab: return (domain: string, path: string) => new GitLabService(domain, path, cfg.name, true); + case CustomRemoteType.Bitbucket: return (domain: string, path: string) => new BitbucketService(domain, path, cfg.protocol, cfg.name, true); + case CustomRemoteType.BitbucketServer: return (domain: string, path: string) => new BitbucketServerService(domain, path, cfg.protocol, cfg.name, true); + case CustomRemoteType.Custom: return (domain: string, path: string) => new CustomService(domain, path, cfg.urls!, cfg.protocol, cfg.name); + case CustomRemoteType.GitHub: return (domain: string, path: string) => new GitHubService(domain, path, cfg.protocol, cfg.name, true); + case CustomRemoteType.GitLab: return (domain: string, path: string) => new GitLabService(domain, path, cfg.protocol, cfg.name, true); } return undefined; } diff --git a/src/git/remotes/github.ts b/src/git/remotes/github.ts index 6a855be..5624468 100644 --- a/src/git/remotes/github.ts +++ b/src/git/remotes/github.ts @@ -7,10 +7,11 @@ export class GitHubService extends RemoteProvider { constructor( domain: string, path: string, + protocol?: string, name?: string, custom: boolean = false ) { - super(domain, path, name, custom); + super(domain, path, protocol, name, custom); } get name() { diff --git a/src/git/remotes/gitlab.ts b/src/git/remotes/gitlab.ts index 57f7b24..af4f187 100644 --- a/src/git/remotes/gitlab.ts +++ b/src/git/remotes/gitlab.ts @@ -7,10 +7,11 @@ export class GitLabService extends RemoteProvider { constructor( domain: string, path: string, + protocol?: string, name?: string, custom: boolean = false ) { - super(domain, path, name, custom); + super(domain, path, protocol, name, custom); } get name() { diff --git a/src/git/remotes/provider.ts b/src/git/remotes/provider.ts index e3fe116..1495a6d 100644 --- a/src/git/remotes/provider.ts +++ b/src/git/remotes/provider.ts @@ -39,8 +39,8 @@ export abstract class RemoteProvider { constructor( public readonly domain: string, public readonly path: string, + private readonly protocol: string = 'https', name?: string, - public readonly protocol: string = 'https' public readonly custom: boolean = false ) { this._name = name; @@ -49,7 +49,7 @@ export abstract class RemoteProvider { abstract get name(): string; protected get baseUrl() { - return `${this.protocol}://${this.domain}/${this.path}`; + return `${this.protocol}://${this.domain}/${this.path}`; } protected formatName(name: string) { diff --git a/src/git/remotes/visualStudio.ts b/src/git/remotes/visualStudio.ts index 6ae57d0..1f48ac9 100644 --- a/src/git/remotes/visualStudio.ts +++ b/src/git/remotes/visualStudio.ts @@ -7,9 +7,10 @@ export class VisualStudioService extends RemoteProvider { constructor( domain: string, path: string, + protocol?: string, name?: string ) { - super(domain, path, name); + super(domain, path, protocol, name); } get name() {