Skip to content

Commit a29e85e

Browse files
author
houlin.cheng
committed
fix issue#207, Response code 401 (Unauthorized)
1 parent a3377e4 commit a29e85e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ function browse(options) {
266266
var page = options.page || ''
267267
if (page === '') {
268268
open(
269-
gitlab.options.url + '/' + projectName + '/tree/' + curBranchName
269+
gitlab.options.host + '/' + projectName + '/tree/' + curBranchName
270270
)
271271
} else {
272-
open(gitlab.options.url + '/' + projectName + '/' + page)
272+
open(gitlab.options.host + '/' + projectName + '/' + page)
273273
}
274274
})
275275
})
@@ -306,7 +306,7 @@ function compare(options) {
306306
var targetBranch = options.target || defaultBranch
307307
var sourceBranch = baseBranch
308308
open(
309-
gitlab.options.url +
309+
gitlab.options.host +
310310
'/' +
311311
projectName +
312312
'/compare/' +
@@ -405,7 +405,7 @@ function openMergeRequests(options) {
405405
}
406406

407407
open(
408-
gitlab.options.url +
408+
gitlab.options.host +
409409
'/' +
410410
projectName +
411411
'/merge_requests' +
@@ -436,7 +436,7 @@ function createMergeRequest(options) {
436436
return getURLOfRemote(remote)
437437
})
438438
.then(function(remoteURL) {
439-
var gitlabHost = URL.parse(gitlab.options.url).host
439+
var gitlabHost = URL.parse(gitlab.options.host).host
440440

441441
logger.log('\ngitlab host obtained : ' + gitlabHost.green)
442442

@@ -586,7 +586,7 @@ function createMergeRequest(options) {
586586

587587
if (!url) {
588588
url =
589-
gitlab.options.url +
589+
gitlab.options.host +
590590
'/' +
591591
targetProjectName +
592592
'/merge_requests/' +

options.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ var git = {
1919
var options = (function () {
2020
var options = {
2121
host: git.config.get('gitlab.url') || process.env.GITLAB_URL,
22-
url: git.config.get('gitlab.url') || process.env.GITLAB_URL,
2322
token: git.config.get('gitlab.token') || process.env.GITLAB_TOKEN,
2423
};
2524

26-
if (!options.url) {
25+
if (!options.host) {
2726
var defaultInput = (function () {
2827
var url = git.config.get('remote.origin.url');
2928
if (!url || url.indexOf('bitbucket') !== -1 || url.indexOf('github') !== -1) {
@@ -32,15 +31,15 @@ var git = {
3231
return 'https://' + gitUrlParse(url).resource;
3332
})();
3433
var urlQuestion = ('Enter GitLab URL (' + defaultInput + '): ').yellow;
35-
while (!options.url) {
36-
options.url = readlineSync.question(urlQuestion, { defaultInput: defaultInput });
34+
while (!options.host) {
35+
options.host = readlineSync.question(urlQuestion, { defaultInput: defaultInput });
3736
urlQuestion = 'Invalid URL (try again): '.red;
3837
}
39-
git.config.set('gitlab.url', options.url);
38+
git.config.set('gitlab.url', options.host);
4039
}
4140

4241
if (!options.token) {
43-
var url = options.url + '/profile/personal_access_tokens';
42+
var url = options.host + '/profile/personal_access_tokens';
4443
console.log('A personal access token is needed to use the GitLab API\n' + url.grey);
4544
var tokenQuestion = 'Enter personal access token: '.yellow;
4645
while (!options.token) {

0 commit comments

Comments
 (0)