From 5fae04014cee8a7456a37a618a903e8a043f0acc Mon Sep 17 00:00:00 2001 From: Ziya Sarikaya Date: Tue, 17 Jul 2018 18:17:37 +0200 Subject: [PATCH] fixes #63 --- package.json | 3 +-- src/extension.js | 2 +- src/gitProvider.js | 13 +++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 017e1cc..281c628 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Open in GitHub, Bitbucket, Gitlab, VisualStudio.com !", "description": "Jump to a source code line in Github, Bitbucket, Gitlab, VisualStudio.com !", "icon": "images/icon_200.png", - "version": "1.3.3", + "version": "1.3.4", "publisher": "ziyasal", "license": "SEE LICENSE IN LICENSE.md", "galleryBanner": { @@ -68,7 +68,6 @@ }, "openInGitHub.providerType": { "type": "string", - "default": "gitlab", "enum": [ "gitlab", "github", diff --git a/src/extension.js b/src/extension.js index 4012e35..f885a39 100644 --- a/src/extension.js +++ b/src/extension.js @@ -55,7 +55,7 @@ function getGitProviderLink(cb, fileFsPath, lines, pr) { } try { - provider = gitProvider(rawUri, sha); + provider = gitProvider(rawUri, sha, branch); } catch (e) { let errmsg = e.toString(); Window.showWarningMessage(`Unknown Git provider. ${errmsg}`); diff --git a/src/gitProvider.js b/src/gitProvider.js index 301e651..05d2cc9 100644 --- a/src/gitProvider.js +++ b/src/gitProvider.js @@ -7,9 +7,10 @@ const path = require('path'); const useCommitSHAInURL = workspace.getConfiguration('openInGitHub').get('useCommitSHAInURL'); class BaseProvider { - constructor(gitUrl, sha) { + constructor(gitUrl, sha, branch) { this.gitUrl = gitUrl; this.sha = sha; + this.branch = branch; } get baseUrl() { @@ -83,7 +84,7 @@ class VisualStudio extends BaseProvider { webUrl(branch, filePath, line, endLine) { let query = { - version: `GB${branch}`, + version: `GB${this.branch}`, }; if (filePath) { query['path'] = filePath; @@ -100,7 +101,7 @@ class VisualStudio extends BaseProvider { } const gitHubDomain = workspace.getConfiguration('openInGitHub').get('gitHubDomain', 'github.com'); -const providerType = workspace.getConfiguration('openInGitHub').get('providerType', 'unknown'); +const providerType = workspace.getConfiguration('openInGitHub').get('providerType', 'unknown') || 'unknown'; const providerProtocol = workspace.getConfiguration('openInGitHub').get('providerProtocol', 'https'); const defaultPrBranch = workspace.getConfiguration('openInGitHub').get('defaultPullRequestBranch', 'integration') @@ -117,13 +118,13 @@ const providers = { * @param {string} remoteUrl * @return {BaseProvider|null} */ -function gitProvider(remoteUrl, sha) { +function gitProvider(remoteUrl, sha, branch) { const gitUrl = gitUrlParse(remoteUrl); for (const domain of Object.keys(providers)) { if (domain === gitUrl.resource || domain === gitUrl.source) { - return new providers[domain](gitUrl, sha); + return new providers[domain](gitUrl, sha, branch); } else if (domain.indexOf(providerType) > -1) { - return new providers[domain](gitUrl, sha); + return new providers[domain](gitUrl, sha, branch); } } throw new Error('unknown Provider');