Welcome to mirror list, hosted at ThFree Co, Russian Federation.

README.md~ « hosted-git-info « node_modules - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f6f1dcf9ecd6a8310c89d181146663a95bab3bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# hosted-git-info

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

```javascript
var hostedGitInfo = require("hosted-git-info")
var info = hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git")
/* 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:

* info.type -- The short name of the service
* info.domain -- The domain for git protocol use
* 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:

* info.file(path)

Given the path of a file relative to the repository, returns a URL for
directly fetching it from the githost.  If no comittish was set then
`master` will be used as the default.

<<<<<<< HEAD
For example `hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git#v1.0.0").file("package.json")`
||||||| merged common ancestors
For example `hostedGitInfo("git@github.com:npm/hosted-git-info.git").file("v1.0.0")`
=======
For example `hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git").file("v1.0.0")`
>>>>>>> Another README fix
would return `https://raw.githubusercontent.com/npm/hosted-git-info/v1.0.0/package.json`

* info.shortcut()

eg, `github:npm/hosted-git-info`

* info.browse()

eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0`

* info.bugs()

eg, `https://github.com/npm/hosted-git-info/issues`

* info.docs()

eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0#readme`

* info.https()

eg, `https://github.com/npm/hosted-git-info.git`

* info.sshurl()

eg, `git+ssh://git@github.com/npm/hosted-git-info.git`

* info.ssh()

eg, `git@github.com:npm/hosted-git-info.git`

* info.path()

eg, `npm/hosted-git-info`

## Supported hosts

Currently this supports Github, Bitbucket and Gitlab. Pull requests for
additional hosts welcome.