From 9b26223a2158d002d92481f60c34baa1169ba242 Mon Sep 17 00:00:00 2001 From: Dmitry Gurovich Date: Thu, 14 Oct 2021 13:29:04 +0000 Subject: [PATCH] Fixes #693: Allow AzureDevOps as custom remote provider --- README.md | 8 ++++---- package.json | 1 + src/config.ts | 1 + src/git/remotes/factory.ts | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ddeb7d..fa92895 100644 --- a/README.md +++ b/README.md @@ -955,10 +955,10 @@ See also [View Settings](#view-settings- 'Jump to the View settings') ## Remote Provider Integration Settings [#](#remote-provider-integration-settings- 'Remote Provider Integration Settings') -| Name | Description | -| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `gitlens.integrations.enabled` | Specifies whether to enable rich integrations with any supported remote services | -| `gitlens.remotes` | Specifies custom remote services to be matched with Git remotes to detect custom domains for built-in remote services or provide support for custom remote services

Supported Types (e.g. `"type": "GitHub"`):Example:
`"gitlens.remotes": [{ "domain": "git.corporate-url.com", "type": "GitHub" }]`

Example:
`"gitlens.remotes": [{ "regex": "ssh:\/\/(my\.company\.com):1234\/git\/(.+)", "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}"`
        `}`
    `}]`

Example:
`"gitlens.remotes": [{`
    `"regex": "ssh:\\/\\/(my\\.company\\.com):1234\\/git\\/(.+)",`
    `"type": "Custom",`
    `"name": "My Company",`
    `"protocol": "https",`
    `"urls": {`
        `"repository": "https://my.company.com/projects/${repoBase}/repos/${repoPath}",`
        `"branches": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/branches",`
        `"branch": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/commits/${branch}",`
        `"commit": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/commit/${id}",`
        `"file": "https://my.company.com/projects/${repoBase}/repos/${repoPath}?path=${file}${line}",`
        `"fileInBranch": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/blob/${branch}/${file}${line}",`
        `"fileInCommit": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/blob/${id}/${file}${line}",`
        `"fileLine": "#L${line}",`
        `"fileRange": "#L${start}-L${end}"`
        `}`
    `}]` | +| Name | Description | +| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.integrations.enabled` | Specifies whether to enable rich integrations with any supported remote services | +| `gitlens.remotes` | Specifies custom remote services to be matched with Git remotes to detect custom domains for built-in remote services or provide support for custom remote services

Supported Types (e.g. `"type": "GitHub"`):Example:
`"gitlens.remotes": [{ "domain": "git.corporate-url.com", "type": "GitHub" }]`

Example:
`"gitlens.remotes": [{ "regex": "ssh:\/\/(my\.company\.com):1234\/git\/(.+)", "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}"`
        `}`
    `}]`

Example:
`"gitlens.remotes": [{`
    `"regex": "ssh:\\/\\/(my\\.company\\.com):1234\\/git\\/(.+)",`
    `"type": "Custom",`
    `"name": "My Company",`
    `"protocol": "https",`
    `"urls": {`
        `"repository": "https://my.company.com/projects/${repoBase}/repos/${repoPath}",`
        `"branches": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/branches",`
        `"branch": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/commits/${branch}",`
        `"commit": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/commit/${id}",`
        `"file": "https://my.company.com/projects/${repoBase}/repos/${repoPath}?path=${file}${line}",`
        `"fileInBranch": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/blob/${branch}/${file}${line}",`
        `"fileInCommit": "https://my.company.com/projects/${repoBase}/repos/${repoPath}/blob/${id}/${file}${line}",`
        `"fileLine": "#L${line}",`
        `"fileRange": "#L${start}-L${end}"`
        `}`
    `}]` | ## Date & Time Settings [#](#date--time-settings- 'Date & Time Settings') diff --git a/package.json b/package.json index 910ca5e..a229818 100644 --- a/package.json +++ b/package.json @@ -1478,6 +1478,7 @@ "type": "string", "enum": [ "Custom", + "AzureDevOps", "Bitbucket", "BitbucketServer", "Gitea", diff --git a/src/config.ts b/src/config.ts index d593706..78c9e5c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -217,6 +217,7 @@ export enum ContributorSorting { } export enum CustomRemoteType { + AzureDevOps = 'AzureDevOps', Bitbucket = 'Bitbucket', BitbucketServer = 'BitbucketServer', Custom = 'Custom', diff --git a/src/git/remotes/factory.ts b/src/git/remotes/factory.ts index ae39174..1f0632d 100644 --- a/src/git/remotes/factory.ts +++ b/src/git/remotes/factory.ts @@ -124,6 +124,8 @@ export class RemoteProviderFactory { private static getCustomProvider(cfg: RemotesConfig) { switch (cfg.type) { + case CustomRemoteType.AzureDevOps: + return (domain: string, path: string) => new AzureDevOpsRemote(domain, path, cfg.protocol, cfg.name, true); case CustomRemoteType.Bitbucket: return (domain: string, path: string) => new BitbucketRemote(domain, path, cfg.protocol, cfg.name, true);