Skip to content

Commit bbcf7b2

Browse files
committedAug 4, 2019
fix: Allow slashes in gitlab project section
Technically these are called groups and subgroups in GitLab parlance, but effectively, it means that a GitLab project url can have a path with unlimited portions, like company/property/team/component.git. This allows passing in unlimited path portions in the full url, and avoids encoding the `project` section akin to how `path` is treated as of 3776fa5 #44 Fix #46 Fix #43
1 parent 60abaea commit bbcf7b2

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed
 

‎git-host-info.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ var gitHosts = module.exports = {
2424
'treepath': 'tree',
2525
'bugstemplate': 'https://{domain}/{user}/{project}/issues',
2626
'httpstemplate': 'git+https://{auth@}{domain}/{user}/{projectPath}.git{#committish}',
27-
'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}'
27+
'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}',
28+
'pathmatch': /^[/]([^/]+)[/](.+?)(?:[.]git|[/])?$/
2829
},
2930
gist: {
3031
'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],

‎git-host.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ GitHost.prototype._fill = function (template, opts) {
5252
var rawProject = vars.project
5353
Object.keys(vars).forEach(function (key) {
5454
var value = vars[key]
55-
if (key === 'path' && typeof value === 'string') {
55+
if ((key === 'path' || key === 'project') && typeof value === 'string') {
5656
vars[key] = value.split('/').map(function (pathComponent) {
5757
return encodeURIComponent(pathComponent)
5858
}).join('/')

‎test/gitlab.js

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ test('fromUrl(gitlab url)', function (t) {
2828
require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab')
2929
require('./lib/standard-tests')(verify, 'www.gitlab.com', 'gitlab')
3030

31+
const subsShort = HostedGit.fromUrl('gitlab:adpt/starters/hello-node')
32+
const subsFull = HostedGit.fromUrl('git+https://gitlab.com/adpt/starters/hello-node.git')
33+
t.ok(subsShort)
34+
t.equal(subsShort.https(), 'git+https://gitlab.com/adpt/starters/hello-node.git')
35+
t.equal(subsShort.ssh(), 'git@gitlab.com:adpt/starters/hello-node.git')
36+
t.ok(subsFull)
37+
t.equal(subsFull.https(), 'git+https://gitlab.com/adpt/starters/hello-node.git')
38+
t.equal(subsFull.ssh(), 'git@gitlab.com:adpt/starters/hello-node.git')
39+
3140
t.is(
3241
HostedGit.fromUrl('gitlab:group/sub group1/subgroup2/repo').https(),
3342
'git+https://gitlab.com/group/sub%20group1/subgroup2/repo.git',

0 commit comments

Comments
 (0)