This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -2,6 +2,93 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="2.8.8"></a>
## [2.8.8](https://github.com/npm/hosted-git-info/compare/v2.8.7...v2.8.8) (2020-02-29)
### Bug Fixes
* [#61](https://github.com/npm/hosted-git-info/issues/61) & [#65](https://github.com/npm/hosted-git-info/issues/65) addressing issues w/ url.URL implmentation which regressed node 6 support ([5038b18](https://github.com/npm/hosted-git-info/commit/5038b18)), closes [#66](https://github.com/npm/hosted-git-info/issues/66)
<a name="2.8.7"></a>
## [2.8.7](https://github.com/npm/hosted-git-info/compare/v2.8.6...v2.8.7) (2020-02-26)
### Bug Fixes
* Do not attempt to use url.URL when unavailable ([2d0bb66](https://github.com/npm/hosted-git-info/commit/2d0bb66)), closes [#61](https://github.com/npm/hosted-git-info/issues/61) [#62](https://github.com/npm/hosted-git-info/issues/62)
* Do not pass scp-style URLs to the WhatWG url.URL ([f2cdfcf](https://github.com/npm/hosted-git-info/commit/f2cdfcf)), closes [#60](https://github.com/npm/hosted-git-info/issues/60)
<a name="2.8.6"></a>
## [2.8.6](https://github.com/npm/hosted-git-info/compare/v2.8.5...v2.8.6) (2020-02-25)
<a name="2.8.5"></a>
## [2.8.5](https://github.com/npm/hosted-git-info/compare/v2.8.4...v2.8.5) (2019-10-07)
### Bug Fixes
* updated pathmatch for gitlab ([e8325b5](https://github.com/npm/hosted-git-info/commit/e8325b5)), closes [#51](https://github.com/npm/hosted-git-info/issues/51)
* updated pathmatch for gitlab ([ffe056f](https://github.com/npm/hosted-git-info/commit/ffe056f))
<a name="2.8.4"></a>
## [2.8.4](https://github.com/npm/hosted-git-info/compare/v2.8.3...v2.8.4) (2019-08-12)
<a name="2.8.3"></a>
## [2.8.3](https://github.com/npm/hosted-git-info/compare/v2.8.2...v2.8.3) (2019-08-12)
<a name="2.8.2"></a>
## [2.8.2](https://github.com/npm/hosted-git-info/compare/v2.8.1...v2.8.2) (2019-08-05)
### Bug Fixes
* http protocol use sshurl by default ([3b1d629](https://github.com/npm/hosted-git-info/commit/3b1d629)), closes [#48](https://github.com/npm/hosted-git-info/issues/48)
<a name="2.8.1"></a>
## [2.8.1](https://github.com/npm/hosted-git-info/compare/v2.8.0...v2.8.1) (2019-08-05)
### Bug Fixes
* ignore noCommittish on tarball url generation ([5d4a8d7](https://github.com/npm/hosted-git-info/commit/5d4a8d7))
* use gist tarball url that works for anonymous gists ([1692435](https://github.com/npm/hosted-git-info/commit/1692435))
<a name="2.8.0"></a>
# [2.8.0](https://github.com/npm/hosted-git-info/compare/v2.7.1...v2.8.0) (2019-08-05)
### Bug Fixes
* Allow slashes in gitlab project section ([bbcf7b2](https://github.com/npm/hosted-git-info/commit/bbcf7b2)), closes [#46](https://github.com/npm/hosted-git-info/issues/46) [#43](https://github.com/npm/hosted-git-info/issues/43)
* **git-host:** disallow URI-encoded slash (%2F) in `path` ([3776fa5](https://github.com/npm/hosted-git-info/commit/3776fa5)), closes [#44](https://github.com/npm/hosted-git-info/issues/44)
* **gitlab:** Do not URL encode slashes in project name for GitLab https URL ([cbf04f9](https://github.com/npm/hosted-git-info/commit/cbf04f9)), closes [#47](https://github.com/npm/hosted-git-info/issues/47)
* do not allow invalid gist urls ([d5cf830](https://github.com/npm/hosted-git-info/commit/d5cf830))
* **cache:** Switch to lru-cache to save ourselves from unlimited memory consumption ([e518222](https://github.com/npm/hosted-git-info/commit/e518222)), closes [#38](https://github.com/npm/hosted-git-info/issues/38)
### Features
* give these objects a name ([60abaea](https://github.com/npm/hosted-git-info/commit/60abaea))
<a name="2.7.1"></a>
## [2.7.1](https://github.com/npm/hosted-git-info/compare/v2.7.0...v2.7.1) (2018-07-07)

View File

@@ -23,12 +23,14 @@ var gitHosts = module.exports = {
'domain': 'gitlab.com',
'treepath': 'tree',
'bugstemplate': 'https://{domain}/{user}/{project}/issues',
'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}'
'httpstemplate': 'git+https://{auth@}{domain}/{user}/{projectPath}.git{#committish}',
'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}',
'pathmatch': /^[/]([^/]+)[/]((?!.*(\/-\/|\/repository\/archive\.tar\.gz\?=.*|\/repository\/[^/]+\/archive.tar.gz$)).*?)(?:[.]git|[/])?$/
},
gist: {
'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
'domain': 'gist.github.com',
'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]+)(?:[.]git)?$/,
'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]{32,})(?:[.]git)?$/,
'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/committish}/{path}',
'bugstemplate': 'https://{domain}/{project}',
'gittemplate': 'git://{domain}/{project}.git{#committish}',
@@ -40,7 +42,7 @@ var gitHosts = module.exports = {
'httpstemplate': 'git+https://{domain}/{project}.git{#committish}',
'shortcuttemplate': '{type}:{project}{#committish}',
'pathtemplate': '{project}{#committish}',
'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz',
'tarballtemplate': 'https://codeload.github.com/gist/{project}/tar.gz/{committish}',
'hashformat': function (fragment) {
return 'file-' + formatHashFragment(fragment)
}

View File

@@ -1,9 +1,24 @@
'use strict'
var gitHosts = require('./git-host-info.js')
/* eslint-disable node/no-deprecated-api */
var extend = Object.assign || require('util')._extend
var GitHost = module.exports = function (type, user, auth, project, committish, defaultRepresentation, opts) {
// copy-pasta util._extend from node's source, to avoid pulling
// the whole util module into peoples' webpack bundles.
/* istanbul ignore next */
var extend = Object.assign || function _extend (target, source) {
// Don't do anything if source isn't an object
if (source === null || typeof source !== 'object') return target
var keys = Object.keys(source)
var i = keys.length
while (i--) {
target[keys[i]] = source[keys[i]]
}
return target
}
module.exports = GitHost
function GitHost (type, user, auth, project, committish, defaultRepresentation, opts) {
var gitHostInfo = this
gitHostInfo.type = type
Object.keys(gitHosts[type]).forEach(function (key) {
@@ -16,7 +31,6 @@ var GitHost = module.exports = function (type, user, auth, project, committish,
gitHostInfo.default = defaultRepresentation
gitHostInfo.opts = opts || {}
}
GitHost.prototype = {}
GitHost.prototype.hash = function () {
return this.committish ? '#' + this.committish : ''
@@ -32,24 +46,33 @@ GitHost.prototype._fill = function (template, opts) {
if (self[key] != null && vars[key] == null) vars[key] = self[key]
})
var rawAuth = vars.auth
var rawComittish = vars.committish
var rawcommittish = vars.committish
var rawFragment = vars.fragment
var rawPath = vars.path
var rawProject = vars.project
Object.keys(vars).forEach(function (key) {
vars[key] = encodeURIComponent(vars[key])
var value = vars[key]
if ((key === 'path' || key === 'project') && typeof value === 'string') {
vars[key] = value.split('/').map(function (pathComponent) {
return encodeURIComponent(pathComponent)
}).join('/')
} else {
vars[key] = encodeURIComponent(value)
}
})
vars['auth@'] = rawAuth ? rawAuth + '@' : ''
vars['#fragment'] = rawFragment ? '#' + this.hashformat(rawFragment) : ''
vars.fragment = vars.fragment ? vars.fragment : ''
vars['#path'] = rawPath ? '#' + this.hashformat(rawPath) : ''
vars['/path'] = vars.path ? '/' + vars.path : ''
vars.projectPath = rawProject.split('/').map(encodeURIComponent).join('/')
if (opts.noCommittish) {
vars['#committish'] = ''
vars['/tree/committish'] = ''
vars['/comittish'] = ''
vars.comittish = ''
vars['/committish'] = ''
vars.committish = ''
} else {
vars['#committish'] = rawComittish ? '#' + rawComittish : ''
vars['#committish'] = rawcommittish ? '#' + rawcommittish : ''
vars['/tree/committish'] = vars.committish
? '/' + vars.treepath + '/' + vars.committish
: ''
@@ -114,7 +137,8 @@ GitHost.prototype.path = function (opts) {
return this._fill(this.pathtemplate, opts)
}
GitHost.prototype.tarball = function (opts) {
GitHost.prototype.tarball = function (opts_) {
var opts = extend({}, opts_, { noCommittish: false })
return this._fill(this.tarballtemplate, opts)
}
@@ -127,5 +151,6 @@ GitHost.prototype.getDefaultRepresentation = function () {
}
GitHost.prototype.toString = function (opts) {
return (this[this.default] || this.sshurl).call(this, opts)
if (this.default && typeof this[this.default] === 'function') return this[this.default](opts)
return this.sshurl(opts)
}

View File

@@ -4,15 +4,14 @@ var gitHosts = require('./git-host-info.js')
var GitHost = module.exports = require('./git-host.js')
var protocolToRepresentationMap = {
'git+ssh': 'sshurl',
'git+https': 'https',
'ssh': 'sshurl',
'git': 'git'
'git+ssh:': 'sshurl',
'git+https:': 'https',
'ssh:': 'sshurl',
'git:': 'git'
}
function protocolToRepresentation (protocol) {
if (protocol.substr(-1) === ':') protocol = protocol.slice(0, -1)
return protocolToRepresentationMap[protocol] || protocol
return protocolToRepresentationMap[protocol] || protocol.slice(0, -1)
}
var authProtocols = {
@@ -48,7 +47,7 @@ function fromUrl (giturl, opts) {
var gitHostInfo = gitHosts[gitHostName]
var auth = null
if (parsed.auth && authProtocols[parsed.protocol]) {
auth = decodeURIComponent(parsed.auth)
auth = parsed.auth
}
var committish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null
var user = null
@@ -65,13 +64,18 @@ function fromUrl (giturl, opts) {
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])
/* istanbul ignore else */
if (matched[1] !== null && matched[1] !== undefined) {
user = decodeURIComponent(matched[1].replace(/^:/, ''))
}
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
/* istanbul ignore else */
if (ex instanceof URIError) {
} else throw ex
}
}).filter(function (gitHostInfo) { return gitHostInfo })
if (matches.length !== 1) return
@@ -101,9 +105,31 @@ function fixupUnqualifiedGist (giturl) {
}
function parseGitUrl (giturl) {
if (typeof giturl !== 'string') giturl = '' + giturl
var matched = giturl.match(/^([^@]+)@([^:/]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/)
if (!matched) return url.parse(giturl)
if (!matched) {
var legacy = url.parse(giturl)
// If we don't have url.URL, then sorry, this is just not fixable.
// This affects Node <= 6.12.
if (legacy.auth && typeof url.URL === 'function') {
// git urls can be in the form of scp-style/ssh-connect strings, like
// git+ssh://user@host.com:some/path, which the legacy url parser
// supports, but WhatWG url.URL class does not. However, the legacy
// parser de-urlencodes the username and password, so something like
// https://user%3An%40me:p%40ss%3Aword@x.com/ becomes
// https://user:n@me:p@ss:word@x.com/ which is all kinds of wrong.
// Pull off just the auth and host, so we dont' get the confusing
// scp-style URL, then pass that to the WhatWG parser to get the
// auth properly escaped.
var authmatch = giturl.match(/[^@]+@[^:/]+/)
/* istanbul ignore else - this should be impossible */
if (authmatch) {
var whatwg = new url.URL(authmatch[0])
legacy.auth = whatwg.username || ''
if (whatwg.password) legacy.auth += ':' + whatwg.password
}
}
return legacy
}
return {
protocol: 'git+ssh:',
slashes: true,

View File

@@ -1,33 +1,27 @@
{
"_args": [
[
"hosted-git-info@2.7.1",
"/Users/pjquirk/Source/GitHub/actions/labeler"
]
],
"_development": true,
"_from": "hosted-git-info@2.7.1",
"_id": "hosted-git-info@2.7.1",
"_from": "hosted-git-info@^2.1.4",
"_id": "hosted-git-info@2.8.8",
"_inBundle": false,
"_integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==",
"_integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==",
"_location": "/hosted-git-info",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "hosted-git-info@2.7.1",
"raw": "hosted-git-info@^2.1.4",
"name": "hosted-git-info",
"escapedName": "hosted-git-info",
"rawSpec": "2.7.1",
"rawSpec": "^2.1.4",
"saveSpec": null,
"fetchSpec": "2.7.1"
"fetchSpec": "^2.1.4"
},
"_requiredBy": [
"/normalize-package-data"
],
"_resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz",
"_spec": "2.7.1",
"_where": "/Users/pjquirk/Source/GitHub/actions/labeler",
"_resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
"_shasum": "7539bd4bc1e0e0a895815a2e0262420b12858488",
"_spec": "hosted-git-info@^2.1.4",
"_where": "/Users/dakale/dev/GitHub/actions/labeler/node_modules/normalize-package-data",
"author": {
"name": "Rebecca Turner",
"email": "me@re-becca.org",
@@ -36,11 +30,13 @@
"bugs": {
"url": "https://github.com/npm/hosted-git-info/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab",
"devDependencies": {
"standard": "^11.0.1",
"standard-version": "^4.3.0",
"tap": "^12.0.1"
"standard-version": "^4.4.0",
"tap": "^12.7.0"
},
"files": [
"index.js",
@@ -62,11 +58,12 @@
"url": "git+https://github.com/npm/hosted-git-info.git"
},
"scripts": {
"postrelease": "npm publish && git push --follow-tags",
"postrelease": "npm publish --tag=ancient-legacy-fixes && git push --follow-tags",
"posttest": "standard",
"prerelease": "npm t",
"pretest": "standard",
"release": "standard-version -s",
"test": "tap -J --nyc-arg=--all --coverage test"
"test": "tap -J --coverage=90 --no-esm test/*.js",
"test:coverage": "tap --coverage-report=html -J --coverage=90 --no-esm test/*.js"
},
"version": "2.7.1"
"version": "2.8.8"
}