Skip to content

Commit

Permalink
Merge pull request #69 from hotoo/feat/remote
Browse files Browse the repository at this point in the history
Feat/remote
  • Loading branch information
hotoo authored Apr 25, 2019
2 parents 9e18cdc + 49cf1fc commit 8d08e40
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion bin/gitopen
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ commander(process.argv, {
// 5. git/hg/svn remote url.
var uri;
try {
uri = gitremote.getRemoteUrl({cwd: process.cwd()});
uri = gitremote.getRemoteUrl({
cwd: process.cwd(),
remote: command.remote,
});
} catch (ex) {
if (command.category === 'snippets/new') {
uri = 'https://github.com/hotoo/gitopen';
Expand Down
2 changes: 1 addition & 1 deletion lib/gitremote.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports.getRemoteUrl = function getRemoteUrl(options) {
}
var cwd = options.cwd || process.cwd();
var uri = child_process.execSync(
'git config remote.' + (options.origin || 'origin') + '.url',
'git config remote.' + (options.remote || 'origin') + '.url',
{cwd: cwd}
).toString().trim();

Expand Down
24 changes: 18 additions & 6 deletions test/gitopen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,12 @@ describe('gitremote()', function() {
resolve(gitremote.getRemoteUrl({cwd: '.'})).should.be.eql('github.com/hotoo/gitopen');
});

it('gitremote.getRemoteUrl({remote})', function() {
it('gitremote.getRemoteUrl({remote})', function(done) {
resolve(gitremote.getRemoteUrl({remote: 'origin'})).should.be.eql('github.com/hotoo/gitopen');
child_process.exec('git remote add gitlab [email protected]:hotoo/gitopen.git', {cwd: '.'}, function(/* err, stdout */) {
resolve(gitremote.getRemoteUrl({remote: 'gitlab'})).should.be.eql('gitlab.com/hotoo/gitopen');
done();
});
});

});
Expand Down Expand Up @@ -460,11 +464,11 @@ describe('$ gitopen', function() {
['pull', '/hotoo/gitopen/compare/' + cwb + '?expand=1'],
['pr compare-branch', '/hotoo/gitopen/compare/compare-branch?expand=1'],
['pull compare-branch', '/hotoo/gitopen/compare/compare-branch?expand=1'],
['pr base-branch:compare-branch', '/hotoo/gitopen/compare/base-branch...compare-branch'],
['pr base/branch:compare/branch', '/hotoo/gitopen/compare/base/branch...compare/branch'],
['pr base-branch...compare-branch', '/hotoo/gitopen/compare/base-branch...compare-branch'],
['pr base/branch...compare/branch', '/hotoo/gitopen/compare/base/branch...compare/branch'],
['pr base/branch+name...compare/branch#name', '/hotoo/gitopen/compare/base/branch%2Bname...compare/branch%23name'],
['pr base-branch:compare-branch', '/hotoo/gitopen/compare/base-branch...compare-branch?expand=1'],
['pr base/branch:compare/branch', '/hotoo/gitopen/compare/base/branch...compare/branch?expand=1'],
['pr base-branch...compare-branch', '/hotoo/gitopen/compare/base-branch...compare-branch?expand=1'],
['pr base/branch...compare/branch', '/hotoo/gitopen/compare/base/branch...compare/branch?expand=1'],
['pr base/branch+name...compare/branch#name', '/hotoo/gitopen/compare/base/branch%2Bname...compare/branch%23name?expand=1'],
['pulls', '/hotoo/gitopen/pulls'],
['prs', '/hotoo/gitopen/pulls'],
['mrs', '/hotoo/gitopen/pulls'],
Expand Down Expand Up @@ -506,6 +510,14 @@ describe('$ gitopen', function() {
});
});

it('$ gitopen --remote gitlab', function(done) {
child_process.exec('./bin/gitopen --verbose --remote gitlab', function(err, stdout) {
should(err).not.be.ok();
stdout.should.be.containEql('URL: https://gitlab.com/hotoo/gitopen\n');
done();
});
});

var git_command_case_in_subdir = [
['../README.md :master', '/hotoo/gitopen/blob/master/README.md'],
['../README.md -b master', '/hotoo/gitopen/blob/master/README.md'],
Expand Down

0 comments on commit 8d08e40

Please sign in to comment.