[Pkg-javascript-commits] [node-hosted-git-info] 01/04: New upstream version 2.5.0

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Fri Nov 10 07:23:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository node-hosted-git-info.

commit 5e59b7c3d3bdc2620ca45c2608749a4a31e97b45
Author: Pirate Praveen <praveen at debian.org>
Date:   Fri Nov 10 12:46:04 2017 +0530

    New upstream version 2.5.0
---
 .gitignore        |  2 ++
 .travis.yml       |  7 +++--
 README.md         | 61 ++++++++++++++++++++++++++++++----------
 git-host-info.js  | 16 +++++++----
 git-host.js       | 84 +++++++++++++++++++++++++++++++++----------------------
 index.js          | 68 +++++++++++++++++++++++++++-----------------
 package.json      | 15 ++++++----
 test/basic.js     | 14 ++++++++++
 test/bitbucket.js |  1 +
 test/gist.js      |  1 +
 test/github.js    |  1 +
 test/gitlab.js    |  1 +
 12 files changed, 185 insertions(+), 86 deletions(-)

diff --git a/.gitignore b/.gitignore
index 58e97a7..77a0ac2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
 *~
 .#
 node_modules
+.nyc_output
+coverage
diff --git a/.travis.yml b/.travis.yml
index 7dc6619..f77cd9a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
 language: node_js
+sudo: false
 node_js:
-  - "0.11"
-  - "0.10"
-script: "npm test"
+  - "7"
+  - "6"
+  - "4"
diff --git a/README.md b/README.md
index 1db47dd..f9db5dd 100644
--- a/README.md
+++ b/README.md
@@ -4,11 +4,11 @@ This will let you identify and transform various git hosts URLs between
 protocols.  It also can tell you what the URL is for the raw path for
 particular file for direct access without git.
 
-## Usage
+## Example
 
 ```javascript
 var hostedGitInfo = require("hosted-git-info")
-var info = hostedGitInfo.fromUrl("git at github.com:npm/hosted-git-info.git")
+var info = hostedGitInfo.fromUrl("git at github.com:npm/hosted-git-info.git", opts)
 /* info looks like:
 {
   type: "github",
@@ -32,9 +32,39 @@ If it does match, the returned object has properties of:
 * info.user -- The name of the user/org on the git host
 * info.project -- The name of the project on the git host
 
-And methods of:
+## Version Contract
+
+The major version will be bumped any time…
+
+* The constructor stops accepting URLs that it previously accepted.
+* A method is removed.
+* A method can no longer accept the number and type of arguments it previously accepted.
+* A method can return a different type than it currently returns.
+
+Implications:
+
+* I do not consider the specific format of the urls returned from, say
+  `.https()` to be a part of the contract.  The contract is that it will
+  return a string that can be used to fetch the repo via HTTPS.  But what
+  that string looks like, specifically, can change.
+* Dropping support for a hosted git provider would constitute a breaking
+  change.
+
+## Usage
+
+### var info = hostedGitInfo.fromUrl(gitSpecifier[, options])
+
+* *gitSpecifer* is a URL of a git repository or a SCP-style specifier of one.
+* *options* is an optional object. It can have the following properties:
+  * *noCommittish* — If true then committishes won't be included in generated URLs.
+  * *noGitPlus* — If true then `git+` won't be prefixed on URLs.
+
+## Methods
+
+All of the methods take the same options as the `fromUrl` factory.  Options
+provided to a method override those provided to the constructor.
 
-* info.file(path)
+* info.file(path, opts)
 
 Given the path of a file relative to the repository, returns a URL for
 directly fetching it from the githost.  If no committish was set then
@@ -43,44 +73,48 @@ directly fetching it from the githost.  If no committish was set then
 For example `hostedGitInfo.fromUrl("git at github.com:npm/hosted-git-info.git#v1.0.0").file("package.json")`
 would return `https://raw.githubusercontent.com/npm/hosted-git-info/v1.0.0/package.json`
 
-* info.shortcut()
+* info.shortcut(opts)
 
 eg, `github:npm/hosted-git-info`
 
-* info.browse()
+* info.browse(opts)
 
 eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0`
 
-* info.bugs()
+* info.bugs(opts)
 
 eg, `https://github.com/npm/hosted-git-info/issues`
 
-* info.docs()
+* info.docs(opts)
 
 eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0#readme`
 
-* info.https()
+* info.https(opts)
 
 eg, `git+https://github.com/npm/hosted-git-info.git`
 
-* info.sshurl()
+* info.sshurl(opts)
 
 eg, `git+ssh://git@github.com/npm/hosted-git-info.git`
 
-* info.ssh()
+* info.ssh(opts)
 
 eg, `git at github.com:npm/hosted-git-info.git`
 
-* info.path()
+* info.path(opts)
 
 eg, `npm/hosted-git-info`
 
+* info.tarball(opts)
+
+eg, `https://github.com/npm/hosted-git-info/archive/v1.2.0.tar.gz`
+
 * info.getDefaultRepresentation()
 
 Returns the default output type. The default output type is based on the
 string you passed in to be parsed
 
-* info.toString()
+* info.toString(opts)
 
 Uses the getDefaultRepresentation to call one of the other methods to get a URL for
 this resource. As such `hostedGitInfo.fromUrl(url).toString()` will give
@@ -91,7 +125,6 @@ form of `org/project` will be normalized to `github:org/project`.
 
 SSH connect strings will be normalized into `git+ssh` URLs.
 
-
 ## Supported hosts
 
 Currently this supports Github, Bitbucket and Gitlab. Pull requests for
diff --git a/git-host-info.js b/git-host-info.js
index 2234333..93cf617 100644
--- a/git-host-info.js
+++ b/git-host-info.js
@@ -9,19 +9,22 @@ var gitHosts = module.exports = {
     'treepath': 'tree',
     'filetemplate': 'https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}',
     'bugstemplate': 'https://{domain}/{user}/{project}/issues',
-    'gittemplate': 'git://{auth@}{domain}/{user}/{project}.git{#committish}'
+    'gittemplate': 'git://{auth@}{domain}/{user}/{project}.git{#committish}',
+    'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz'
   },
   bitbucket: {
     'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
     'domain': 'bitbucket.org',
-    'treepath': 'src'
+    'treepath': 'src',
+    'tarballtemplate': 'https://{domain}/{user}/{project}/get/{committish}.tar.gz'
   },
   gitlab: {
     'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
     'domain': 'gitlab.com',
     'treepath': 'tree',
     'docstemplate': 'https://{domain}/{user}/{project}{/tree/committish}#README',
-    'bugstemplate': 'https://{domain}/{user}/{project}/issues'
+    'bugstemplate': 'https://{domain}/{user}/{project}/issues',
+    'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}'
   },
   gist: {
     'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
@@ -36,7 +39,8 @@ var gitHosts = module.exports = {
     'docstemplate': 'https://{domain}/{project}{/committish}',
     'httpstemplate': 'git+https://{domain}/{project}.git{#committish}',
     'shortcuttemplate': '{type}:{project}{#committish}',
-    'pathtemplate': '{project}{#committish}'
+    'pathtemplate': '{project}{#committish}',
+    'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz'
   }
 }
 
@@ -49,7 +53,7 @@ var gitHostDefaults = {
   'filetemplate': 'https://{domain}/{user}/{project}/raw/{committish}/{path}',
   'shortcuttemplate': '{type}:{user}/{project}{#committish}',
   'pathtemplate': '{user}/{project}{#committish}',
-  'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git)?$/
+  'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git|[/])?$/
 }
 
 Object.keys(gitHosts).forEach(function (name) {
@@ -59,6 +63,6 @@ Object.keys(gitHosts).forEach(function (name) {
   })
   gitHosts[name].protocols_re = RegExp('^(' +
     gitHosts[name].protocols.map(function (protocol) {
-      return protocol.replace(/([\\+*{}()\[\]$^|])/g, '\\$1')
+      return protocol.replace(/([\\+*{}()[\]$^|])/g, '\\$1')
     }).join('|') + '):$')
 })
diff --git a/git-host.js b/git-host.js
index ea31380..4c6641b 100644
--- a/git-host.js
+++ b/git-host.js
@@ -1,7 +1,8 @@
 'use strict'
 var gitHosts = require('./git-host-info.js')
+var extend = Object.assign || require('util')._extend
 
-var GitHost = module.exports = function (type, user, auth, project, committish, defaultRepresentation) {
+var GitHost = module.exports = function (type, user, auth, project, committish, defaultRepresentation, opts) {
   var gitHostInfo = this
   gitHostInfo.type = type
   Object.keys(gitHosts[type]).forEach(function (key) {
@@ -12,6 +13,7 @@ var GitHost = module.exports = function (type, user, auth, project, committish,
   gitHostInfo.project = project
   gitHostInfo.committish = committish
   gitHostInfo.default = defaultRepresentation
+  gitHostInfo.opts = opts || {}
 }
 GitHost.prototype = {}
 
@@ -19,9 +21,10 @@ GitHost.prototype.hash = function () {
   return this.committish ? '#' + this.committish : ''
 }
 
-GitHost.prototype._fill = function (template, vars) {
+GitHost.prototype._fill = function (template, opts) {
   if (!template) return
-  if (!vars) vars = {}
+  var vars = extend({}, opts)
+  opts = extend(extend({}, this.opts), opts)
   var self = this
   Object.keys(this).forEach(function (key) {
     if (self[key] != null && vars[key] == null) vars[key] = self[key]
@@ -32,65 +35,80 @@ GitHost.prototype._fill = function (template, vars) {
     vars[key] = encodeURIComponent(vars[key])
   })
   vars['auth@'] = rawAuth ? rawAuth + '@' : ''
-  vars['#committish'] = rawComittish ? '#' + rawComittish : ''
-  vars['/tree/committish'] = vars.committish
-                          ? '/' + vars.treepath + '/' + vars.committish
-                          : ''
-  vars['/committish'] = vars.committish ? '/' + vars.committish : ''
-  vars.committish = vars.committish || 'master'
+  if (opts.noCommittish) {
+    vars['#committish'] = ''
+    vars['/tree/committish'] = ''
+    vars['/comittish'] = ''
+    vars.comittish = ''
+  } else {
+    vars['#committish'] = rawComittish ? '#' + rawComittish : ''
+    vars['/tree/committish'] = vars.committish
+                            ? '/' + vars.treepath + '/' + vars.committish
+                            : ''
+    vars['/committish'] = vars.committish ? '/' + vars.committish : ''
+    vars.committish = vars.committish || 'master'
+  }
   var res = template
   Object.keys(vars).forEach(function (key) {
     res = res.replace(new RegExp('[{]' + key + '[}]', 'g'), vars[key])
   })
-  return res
+  if (opts.noGitPlus) {
+    return res.replace(/^git[+]/, '')
+  } else {
+    return res
+  }
 }
 
-GitHost.prototype.ssh = function () {
-  return this._fill(this.sshtemplate)
+GitHost.prototype.ssh = function (opts) {
+  return this._fill(this.sshtemplate, opts)
 }
 
-GitHost.prototype.sshurl = function () {
-  return this._fill(this.sshurltemplate)
+GitHost.prototype.sshurl = function (opts) {
+  return this._fill(this.sshurltemplate, opts)
 }
 
-GitHost.prototype.browse = function () {
-  return this._fill(this.browsetemplate)
+GitHost.prototype.browse = function (opts) {
+  return this._fill(this.browsetemplate, opts)
 }
 
-GitHost.prototype.docs = function () {
-  return this._fill(this.docstemplate)
+GitHost.prototype.docs = function (opts) {
+  return this._fill(this.docstemplate, opts)
 }
 
-GitHost.prototype.bugs = function () {
-  return this._fill(this.bugstemplate)
+GitHost.prototype.bugs = function (opts) {
+  return this._fill(this.bugstemplate, opts)
 }
 
-GitHost.prototype.https = function () {
-  return this._fill(this.httpstemplate)
+GitHost.prototype.https = function (opts) {
+  return this._fill(this.httpstemplate, opts)
 }
 
-GitHost.prototype.git = function () {
-  return this._fill(this.gittemplate)
+GitHost.prototype.git = function (opts) {
+  return this._fill(this.gittemplate, opts)
 }
 
-GitHost.prototype.shortcut = function () {
-  return this._fill(this.shortcuttemplate)
+GitHost.prototype.shortcut = function (opts) {
+  return this._fill(this.shortcuttemplate, opts)
 }
 
-GitHost.prototype.path = function () {
-  return this._fill(this.pathtemplate)
+GitHost.prototype.path = function (opts) {
+  return this._fill(this.pathtemplate, opts)
 }
 
-GitHost.prototype.file = function (P) {
-  return this._fill(this.filetemplate, {
+GitHost.prototype.tarball = function (opts) {
+  return this._fill(this.tarballtemplate, opts)
+}
+
+GitHost.prototype.file = function (P, opts) {
+  return this._fill(this.filetemplate, extend({
     path: P.replace(/^[/]+/g, '')
-  })
+  }, opts))
 }
 
 GitHost.prototype.getDefaultRepresentation = function () {
   return this.default
 }
 
-GitHost.prototype.toString = function () {
-  return (this[this.default] || this.sshurl).call(this)
+GitHost.prototype.toString = function (opts) {
+  return (this[this.default] || this.sshurl).call(this, opts)
 }
diff --git a/index.js b/index.js
index 453ce87..9055ab1 100644
--- a/index.js
+++ b/index.js
@@ -23,37 +23,55 @@ var authProtocols = {
   'git+http:': true
 }
 
-module.exports.fromUrl = function (giturl) {
+var cache = {}
+
+module.exports.fromUrl = function (giturl, opts) {
+  var key = giturl + JSON.stringify(opts || {})
+
+  if (!(key in cache)) {
+    cache[key] = fromUrl(giturl, opts)
+  }
+
+  return cache[key]
+}
+
+function fromUrl (giturl, opts) {
   if (giturl == null || giturl === '') return
   var url = fixupUnqualifiedGist(
     isGitHubShorthand(giturl) ? 'github:' + giturl : giturl
   )
   var parsed = parseGitUrl(url)
+  var shortcutMatch = url.match(new RegExp('^([^:]+):(?:(?:[^@:]+(?:[^@]+)?@)?([^/]*))[/](.+?)(?:[.]git)?($|#)'))
   var matches = Object.keys(gitHosts).map(function (gitHostName) {
-    var gitHostInfo = gitHosts[gitHostName]
-    var auth = null
-    if (parsed.auth && authProtocols[parsed.protocol]) {
-      auth = decodeURIComponent(parsed.auth)
-    }
-    var committish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null
-    var user = null
-    var project = null
-    var defaultRepresentation = null
-    if (parsed.protocol === gitHostName + ':') {
-      user = decodeURIComponent(parsed.host)
-      project = parsed.path && decodeURIComponent(parsed.path.replace(/^[/](.*?)(?:[.]git)?$/, '$1'))
-      defaultRepresentation = 'shortcut'
-    } else {
-      if (parsed.host !== gitHostInfo.domain) return
-      if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
-      var pathmatch = gitHostInfo.pathmatch
-      var matched = parsed.path.match(pathmatch)
-      if (!matched) return
-      if (matched[1] != null) user = decodeURIComponent(matched[1])
-      if (matched[2] != null) project = decodeURIComponent(matched[2])
-      defaultRepresentation = protocolToRepresentation(parsed.protocol)
+    try {
+      var gitHostInfo = gitHosts[gitHostName]
+      var auth = null
+      if (parsed.auth && authProtocols[parsed.protocol]) {
+        auth = decodeURIComponent(parsed.auth)
+      }
+      var committish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null
+      var user = null
+      var project = null
+      var defaultRepresentation = null
+      if (shortcutMatch && shortcutMatch[1] === gitHostName) {
+        user = shortcutMatch[2] && decodeURIComponent(shortcutMatch[2])
+        project = decodeURIComponent(shortcutMatch[3])
+        defaultRepresentation = 'shortcut'
+      } else {
+        if (parsed.host !== gitHostInfo.domain) return
+        if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
+        if (!parsed.path) return
+        var pathmatch = gitHostInfo.pathmatch
+        var matched = parsed.path.match(pathmatch)
+        if (!matched) return
+        if (matched[1] != null) user = decodeURIComponent(matched[1].replace(/^:/, ''))
+        if (matched[2] != null) project = decodeURIComponent(matched[2])
+        defaultRepresentation = protocolToRepresentation(parsed.protocol)
+      }
+      return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation, opts)
+    } catch (ex) {
+      if (!(ex instanceof URIError)) throw ex
     }
-    return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation)
   }).filter(function (gitHostInfo) { return gitHostInfo })
   if (matches.length !== 1) return
   return matches[0]
@@ -83,7 +101,7 @@ function fixupUnqualifiedGist (giturl) {
 
 function parseGitUrl (giturl) {
   if (typeof giturl !== 'string') giturl = '' + giturl
-  var matched = giturl.match(/^([^@]+)@([^:]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/)
+  var matched = giturl.match(/^([^@]+)@([^:/]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/)
   if (!matched) return url.parse(giturl)
   return {
     protocol: 'git+ssh:',
diff --git a/package.json b/package.json
index f24e39d..c24d163 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "hosted-git-info",
-  "version": "2.1.5",
+  "version": "2.5.0",
   "description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab",
   "main": "index.js",
   "repository": {
@@ -20,10 +20,15 @@
   },
   "homepage": "https://github.com/npm/hosted-git-info",
   "scripts": {
-    "test": "standard && tap test/*.js"
+    "test": "standard && tap -J --coverage test/*.js"
   },
   "devDependencies": {
-    "standard": "^3.3.2",
-    "tap": "^0.4.13"
-  }
+    "standard": "^9.0.2",
+    "tap": "^10.3.0"
+  },
+  "files": [
+    "index.js",
+    "git-host.js",
+    "git-host-info.js"
+  ]
 }
diff --git a/test/basic.js b/test/basic.js
index 0b93f50..2c73497 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -5,11 +5,25 @@ var test = require('tap').test
 test('basic', function (t) {
   t.is(HostedGit.fromUrl('https://google.com'), undefined, 'null on failure')
   t.is(HostedGit.fromUrl('https://github.com/abc/def').getDefaultRepresentation(), 'https', 'match https urls')
+  t.is(HostedGit.fromUrl('https://github.com/abc/def/').getDefaultRepresentation(), 'https', 'match URLs with a trailing slash')
   t.is(HostedGit.fromUrl('ssh://git@github.com/abc/def').getDefaultRepresentation(), 'sshurl', 'match ssh urls')
   t.is(HostedGit.fromUrl('git+ssh://git@github.com/abc/def').getDefaultRepresentation(), 'sshurl', 'match git+ssh urls')
   t.is(HostedGit.fromUrl('git+https://github.com/abc/def').getDefaultRepresentation(), 'https', 'match git+https urls')
   t.is(HostedGit.fromUrl('git at github.com:abc/def').getDefaultRepresentation(), 'sshurl', 'match ssh connect strings')
   t.is(HostedGit.fromUrl('git://github.com/abc/def').getDefaultRepresentation(), 'git', 'match git urls')
   t.is(HostedGit.fromUrl('github:abc/def').getDefaultRepresentation(), 'shortcut', 'match shortcuts')
+
+  t.is(HostedGit.fromUrl('git+ssh://git@nothosted.com/abc/def'), undefined, 'non-hosted URLs get undefined response')
+  t.is(HostedGit.fromUrl('git://nothosted.com'), undefined, 'non-hosted empty URLs get undefined response')
+  t.is(HostedGit.fromUrl('git://github.com/balderdashy/waterline-%s.git'), undefined, 'invalid URLs get undefined response')
+  t.is(HostedGit.fromUrl('git://github.com'), undefined, 'Invalid hosted URLs get undefined response')
+
+  t.is(HostedGit.fromUrl('dEf/AbC').https(), 'git+https://github.com/dEf/AbC.git', 'mixed case shortcut')
+  t.is(HostedGit.fromUrl('gitlab:dEf/AbC').https(), 'git+https://gitlab.com/dEf/AbC.git', 'mixed case prefixed shortcut')
+  t.is(HostedGit.fromUrl('gitlab:dEf/AbC.git').https(), 'git+https://gitlab.com/dEf/AbC.git', 'mixed case prefixed shortcut')
+  t.is(HostedGit.fromUrl('git://github.com/dEf/AbC.git').https(), 'git+https://github.com/dEf/AbC.git', 'mixed case url')
+  t.is(HostedGit.fromUrl('gist:123').https(), 'git+https://gist.github.com/123.git', 'non-user shortcut')
+
+  t.is(HostedGit.fromUrl('git+https://github.com:foo/repo.git#master').https(), 'git+https://github.com/foo/repo.git#master', 'scp style urls are upgraded')
   t.end()
 })
diff --git a/test/bitbucket.js b/test/bitbucket.js
index 72e4ba1..d50f70c 100644
--- a/test/bitbucket.js
+++ b/test/bitbucket.js
@@ -15,6 +15,7 @@ test('fromUrl(bitbucket url)', function (t) {
     t.is(hostinfo.sshurl(), 'git+ssh://git@bitbucket.org/111/222.git' + hash, label + ' -> sshurl')
     t.is(hostinfo.shortcut(), 'bitbucket:111/222' + hash, label + ' -> shortcut')
     t.is(hostinfo.file('C'), 'https://bitbucket.org/111/222/raw/' + (branch || 'master') + '/C', label + ' -> file')
+    t.is(hostinfo.tarball(), 'https://bitbucket.org/111/222/get/' + (branch || 'master') + '.tar.gz', label + ' -> tarball')
   }
 
   require('./lib/standard-tests')(verify, 'bitbucket.org', 'bitbucket')
diff --git a/test/gist.js b/test/gist.js
index cf36d3c..c9573f4 100644
--- a/test/gist.js
+++ b/test/gist.js
@@ -18,6 +18,7 @@ test('fromUrl(gist url)', function (t) {
     t.is(hostinfo.shortcut(), 'gist:222' + hash, label + ' -> shortcut')
     if (hostinfo.user) {
       t.is(hostinfo.file('C'), 'https://gist.githubusercontent.com/111/222/raw/' + (branch ? branch + '/' : '') + 'C', label + ' -> file')
+      t.is(hostinfo.tarball(), 'https://gist.github.com/111/222/archive/' + (branch || 'master') + '.tar.gz', label + ' -> tarball')
     }
   }
 
diff --git a/test/github.js b/test/github.js
index 56098a3..407c050 100644
--- a/test/github.js
+++ b/test/github.js
@@ -17,6 +17,7 @@ test('fromUrl(github url)', function (t) {
     t.is(hostinfo.sshurl(), 'git+ssh://git@github.com/111/222.git' + hash, label + ' -> sshurl')
     t.is(hostinfo.shortcut(), 'github:111/222' + hash, label + ' -> shortcut')
     t.is(hostinfo.file('C'), 'https://raw.githubusercontent.com/111/222/' + (branch || 'master') + '/C', label + ' -> file')
+    t.is(hostinfo.tarball(), 'https://github.com/111/222/archive/' + (branch || 'master') + '.tar.gz', label + ' -> tarball')
   }
 
   // github shorturls
diff --git a/test/gitlab.js b/test/gitlab.js
index 315c908..bf07ae7 100644
--- a/test/gitlab.js
+++ b/test/gitlab.js
@@ -15,6 +15,7 @@ test('fromUrl(gitlab url)', function (t) {
     t.is(hostinfo.sshurl(), 'git+ssh://git@gitlab.com/111/222.git' + hash, label + ' -> sshurl')
     t.is(hostinfo.shortcut(), 'gitlab:111/222' + hash, label + ' -> shortcut')
     t.is(hostinfo.file('C'), 'https://gitlab.com/111/222/raw/' + (branch || 'master') + '/C', label + ' -> file')
+    t.is(hostinfo.tarball(), 'https://gitlab.com/111/222/repository/archive.tar.gz?ref=' + (branch || 'master'), label + ' -> tarball')
   }
 
   require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-hosted-git-info.git



More information about the Pkg-javascript-commits mailing list