Initial commit
[yaffs-website] / node_modules / hosted-git-info / git-host-info.js
1 'use strict'
2
3 var gitHosts = module.exports = {
4   github: {
5     // First two are insecure and generally shouldn't be used any more, but
6     // they are still supported.
7     'protocols': [ 'git', 'http', 'git+ssh', 'git+https', 'ssh', 'https' ],
8     'domain': 'github.com',
9     'treepath': 'tree',
10     'filetemplate': 'https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}',
11     'bugstemplate': 'https://{domain}/{user}/{project}/issues',
12     'gittemplate': 'git://{auth@}{domain}/{user}/{project}.git{#committish}',
13     'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz'
14   },
15   bitbucket: {
16     'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
17     'domain': 'bitbucket.org',
18     'treepath': 'src',
19     'tarballtemplate': 'https://{domain}/{user}/{project}/get/{committish}.tar.gz'
20   },
21   gitlab: {
22     'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
23     'domain': 'gitlab.com',
24     'treepath': 'tree',
25     'docstemplate': 'https://{domain}/{user}/{project}{/tree/committish}#README',
26     'bugstemplate': 'https://{domain}/{user}/{project}/issues',
27     'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}'
28   },
29   gist: {
30     'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
31     'domain': 'gist.github.com',
32     'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]+)(?:[.]git)?$/,
33     'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/committish}/{path}',
34     'bugstemplate': 'https://{domain}/{project}',
35     'gittemplate': 'git://{domain}/{project}.git{#committish}',
36     'sshtemplate': 'git@{domain}:/{project}.git{#committish}',
37     'sshurltemplate': 'git+ssh://git@{domain}/{project}.git{#committish}',
38     'browsetemplate': 'https://{domain}/{project}{/committish}',
39     'docstemplate': 'https://{domain}/{project}{/committish}',
40     'httpstemplate': 'git+https://{domain}/{project}.git{#committish}',
41     'shortcuttemplate': '{type}:{project}{#committish}',
42     'pathtemplate': '{project}{#committish}',
43     'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz'
44   }
45 }
46
47 var gitHostDefaults = {
48   'sshtemplate': 'git@{domain}:{user}/{project}.git{#committish}',
49   'sshurltemplate': 'git+ssh://git@{domain}/{user}/{project}.git{#committish}',
50   'browsetemplate': 'https://{domain}/{user}/{project}{/tree/committish}',
51   'docstemplate': 'https://{domain}/{user}/{project}{/tree/committish}#readme',
52   'httpstemplate': 'git+https://{auth@}{domain}/{user}/{project}.git{#committish}',
53   'filetemplate': 'https://{domain}/{user}/{project}/raw/{committish}/{path}',
54   'shortcuttemplate': '{type}:{user}/{project}{#committish}',
55   'pathtemplate': '{user}/{project}{#committish}',
56   'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git)?$/
57 }
58
59 Object.keys(gitHosts).forEach(function (name) {
60   Object.keys(gitHostDefaults).forEach(function (key) {
61     if (gitHosts[name][key]) return
62     gitHosts[name][key] = gitHostDefaults[key]
63   })
64   gitHosts[name].protocols_re = RegExp('^(' +
65     gitHosts[name].protocols.map(function (protocol) {
66       return protocol.replace(/([\\+*{}()\[\]$^|])/g, '\\$1')
67     }).join('|') + '):$')
68 })