Нет описания

git-host-info.js 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. 'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz'
  13. },
  14. bitbucket: {
  15. 'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
  16. 'domain': 'bitbucket.org',
  17. 'treepath': 'src',
  18. 'tarballtemplate': 'https://{domain}/{user}/{project}/get/{committish}.tar.gz'
  19. },
  20. gitlab: {
  21. 'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
  22. 'domain': 'gitlab.com',
  23. 'treepath': 'tree',
  24. 'docstemplate': 'https://{domain}/{user}/{project}{/tree/committish}#README',
  25. 'bugstemplate': 'https://{domain}/{user}/{project}/issues',
  26. 'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}'
  27. },
  28. gist: {
  29. 'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
  30. 'domain': 'gist.github.com',
  31. 'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]+)(?:[.]git)?$/,
  32. 'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/committish}/{path}',
  33. 'bugstemplate': 'https://{domain}/{project}',
  34. 'gittemplate': 'git://{domain}/{project}.git{#committish}',
  35. 'sshtemplate': 'git@{domain}:/{project}.git{#committish}',
  36. 'sshurltemplate': 'git+ssh://git@{domain}/{project}.git{#committish}',
  37. 'browsetemplate': 'https://{domain}/{project}{/committish}',
  38. 'docstemplate': 'https://{domain}/{project}{/committish}',
  39. 'httpstemplate': 'git+https://{domain}/{project}.git{#committish}',
  40. 'shortcuttemplate': '{type}:{project}{#committish}',
  41. 'pathtemplate': '{project}{#committish}',
  42. 'tarballtemplate': 'https://{domain}/{user}/{project}/archive/{committish}.tar.gz'
  43. }
  44. }
  45. var gitHostDefaults = {
  46. 'sshtemplate': 'git@{domain}:{user}/{project}.git{#committish}',
  47. 'sshurltemplate': 'git+ssh://git@{domain}/{user}/{project}.git{#committish}',
  48. 'browsetemplate': 'https://{domain}/{user}/{project}{/tree/committish}',
  49. 'docstemplate': 'https://{domain}/{user}/{project}{/tree/committish}#readme',
  50. 'httpstemplate': 'git+https://{auth@}{domain}/{user}/{project}.git{#committish}',
  51. 'filetemplate': 'https://{domain}/{user}/{project}/raw/{committish}/{path}',
  52. 'shortcuttemplate': '{type}:{user}/{project}{#committish}',
  53. 'pathtemplate': '{user}/{project}{#committish}',
  54. 'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git|[/])?$/
  55. }
  56. Object.keys(gitHosts).forEach(function (name) {
  57. Object.keys(gitHostDefaults).forEach(function (key) {
  58. if (gitHosts[name][key]) return
  59. gitHosts[name][key] = gitHostDefaults[key]
  60. })
  61. gitHosts[name].protocols_re = RegExp('^(' +
  62. gitHosts[name].protocols.map(function (protocol) {
  63. return protocol.replace(/([\\+*{}()[\]$^|])/g, '\\$1')
  64. }).join('|') + '):$')
  65. })