Skip to content

Commit

Permalink
fixes #63
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziya Sarikaya committed Jul 17, 2018
1 parent 133c0a3 commit 5fae040
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -68,7 +68,6 @@
},
"openInGitHub.providerType": {
"type": "string",
"default": "gitlab",
"enum": [
"gitlab",
"github",
Expand Down
2 changes: 1 addition & 1 deletion src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
13 changes: 7 additions & 6 deletions src/gitProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand All @@ -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')

Expand All @@ -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');
Expand Down

0 comments on commit 5fae040

Please sign in to comment.