Tennessee Gibbs 0304752480 added pages to master | 6 년 전 | |
---|---|---|
.. | ||
CHANGELOG.md | 6 년 전 | |
LICENSE | 6 년 전 | |
README.md | 6 년 전 | |
git-host-info.js | 6 년 전 | |
git-host.js | 6 년 전 | |
index.js | 6 년 전 | |
package.json | 6 년 전 |
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.
var hostedGitInfo = require("hosted-git-info")
var info = hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git", opts)
/* info looks like:
{
type: "github",
domain: "github.com",
user: "npm",
project: "hosted-git-info"
}
*/
If the URL can't be matched with a git host, null
will be returned. We
can match git, ssh and https urls. Additionally, we can match ssh connect
strings (git@github.com:npm/hosted-git-info
) and shortcuts (eg,
github:npm/hosted-git-info
). Github specifically, is detected in the case
of a third, unprefixed, form: npm/hosted-git-info
.
If it does match, the returned object has properties of:
The major version will be bumped any time…
Implications:
.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.git+
won't be prefixed on URLs.All of the methods take the same options as the fromUrl
factory. Options
provided to a method override those provided to the constructor.
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
master
will be used as the default.
For example hostedGitInfo.fromUrl("git@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
eg, github:npm/hosted-git-info
eg, https://github.com/npm/hosted-git-info/tree/v1.2.0
,
https://github.com/npm/hosted-git-info/tree/v1.2.0/package.json
,
https://github.com/npm/hosted-git-info/tree/v1.2.0/REAMDE.md#supported-hosts
eg, https://github.com/npm/hosted-git-info/issues
eg, https://github.com/npm/hosted-git-info/tree/v1.2.0#readme
eg, git+https://github.com/npm/hosted-git-info.git
eg, git+ssh://git@github.com/npm/hosted-git-info.git
eg, git@github.com:npm/hosted-git-info.git
eg, npm/hosted-git-info
eg, https://github.com/npm/hosted-git-info/archive/v1.2.0.tar.gz
Returns the default output type. The default output type is based on the string you passed in to be parsed
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
you a normalized version of the URL that still uses the same protocol.
Shortcuts will still be returned as shortcuts, but the special case github
form of org/project
will be normalized to github:org/project
.
SSH connect strings will be normalized into git+ssh
URLs.
Currently this supports Github, Bitbucket and Gitlab. Pull requests for additional hosts welcome.