git-host-info.js 2.8 KB

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