UI for Zipcoin Blue

git-host-info.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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://codeload.{domain}/{user}/{project}/tar.gz/{committish}'
  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. 'bugstemplate': 'https://{domain}/{user}/{project}/issues',
  25. 'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}'
  26. },
  27. gist: {
  28. 'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
  29. 'domain': 'gist.github.com',
  30. 'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]+)(?:[.]git)?$/,
  31. 'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/committish}/{path}',
  32. 'bugstemplate': 'https://{domain}/{project}',
  33. 'gittemplate': 'git://{domain}/{project}.git{#committish}',
  34. 'sshtemplate': 'git@{domain}:/{project}.git{#committish}',
  35. 'sshurltemplate': 'git+ssh://git@{domain}/{project}.git{#committish}',
  36. 'browsetemplate': 'https://{domain}/{project}{/committish}',
  37. 'browsefiletemplate': 'https://{domain}/{project}{/committish}{#path}',
  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. 'hashformat': function (fragment) {
  44. return 'file-' + formatHashFragment(fragment)
  45. }
  46. }
  47. }
  48. var gitHostDefaults = {
  49. 'sshtemplate': 'git@{domain}:{user}/{project}.git{#committish}',
  50. 'sshurltemplate': 'git+ssh://git@{domain}/{user}/{project}.git{#committish}',
  51. 'browsetemplate': 'https://{domain}/{user}/{project}{/tree/committish}',
  52. 'browsefiletemplate': 'https://{domain}/{user}/{project}/{treepath}/{committish}/{path}{#fragment}',
  53. 'docstemplate': 'https://{domain}/{user}/{project}{/tree/committish}#readme',
  54. 'httpstemplate': 'git+https://{auth@}{domain}/{user}/{project}.git{#committish}',
  55. 'filetemplate': 'https://{domain}/{user}/{project}/raw/{committish}/{path}',
  56. 'shortcuttemplate': '{type}:{user}/{project}{#committish}',
  57. 'pathtemplate': '{user}/{project}{#committish}',
  58. 'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git|[/])?$/,
  59. 'hashformat': formatHashFragment
  60. }
  61. Object.keys(gitHosts).forEach(function (name) {
  62. Object.keys(gitHostDefaults).forEach(function (key) {
  63. if (gitHosts[name][key]) return
  64. gitHosts[name][key] = gitHostDefaults[key]
  65. })
  66. gitHosts[name].protocols_re = RegExp('^(' +
  67. gitHosts[name].protocols.map(function (protocol) {
  68. return protocol.replace(/([\\+*{}()[\]$^|])/g, '\\$1')
  69. }).join('|') + '):$')
  70. })
  71. function formatHashFragment (fragment) {
  72. return fragment.toLowerCase().replace(/^\W+|\/|\W+$/g, '').replace(/\W+/g, '-')
  73. }