555
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

repo-manifest.js 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. module.exports = ((name, options)=>{
  2. options = options || { username : ``, reposerver : `https://git.bbh.org.in` }
  3. utils = options.utils
  4. // Default set of users in main repos.
  5. var users = [
  6. { username : `${options.username}`, password : `${options.password}` }
  7. , { username : `guest`}
  8. // , { username : `baptistdev`, password : 'encrypted' }
  9. // , { username : `guest`, password : 'encrypted' }
  10. ]
  11. // ${options.reposerver} should be used to lookup current config.
  12. // User can always add more branches and remotes as needed. Mainifest defines and occupies
  13. // a dictionary of well defined remote names
  14. var remotes = { // these are both fetch and push remotes. Use push - remotes to override push.
  15. 'chess' : {
  16. priority : 0,
  17. // PB : TODO -- Handle cases where a repository url can be accessed by multiple users...
  18. server : `${options.reposerver}`, user : options.username || '', path : ``
  19. , get url(){ return `${this.server}/chess/${this.path}`} // fetch
  20. , push : 'no-pushing'
  21. , title : 'chess'
  22. }
  23. , 'chess-public' : { priority : 1,
  24. server : `https://git.bbh.org.in`, user : options.username || '', path : ``
  25. , get url(){ return `${this.server}/chess/${this.path}`}
  26. , title : 'chess-public' // PB : TODO -- rename...
  27. , accessibility : ['public']
  28. , push : 'no-pushing'
  29. }
  30. // PB : TODO -- Load private repositories from private config...
  31. , 'chess-private' : { priority : 2,
  32. server : `http://git.bbh`, user : options.username || '', path : ``
  33. , get url(){ return `${this.server}/chess/${this.path}`}
  34. , title : 'chess-private'
  35. , accessibility : ['private']
  36. , push : 'no-pushing', private : true
  37. }
  38. , 'chess-github' : { priority : 3,
  39. server : `https://github.com`, user : 'baptistdev', path : ``
  40. , get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
  41. , title : 'chess-github'
  42. , accessibility : ['public']
  43. , push : 'no-pushing' //, external : true, public : true
  44. }
  45. }
  46. // Multiple urls dont tell us the current origin which may be
  47. // different based on currently available/accessible based on device and client.
  48. // We just treat them as different remotes and merge as needed.
  49. if(options.username) {
  50. utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }
  51. , remotes
  52. , { 'userfork' : {
  53. priority : 1,
  54. server : `${options.reposerver}`, user : `${options.username}`, path : ``
  55. , get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
  56. , title : 'userfork'
  57. }
  58. , 'userfork-public' : {
  59. priority : 1,
  60. server : `https://git.bbh.org.in`, user : `${options.username}`, path : ``
  61. , get url(){ return `${this.server}/${this.user}/${this.path}`}
  62. // PB : TODO - Other users may have access to this users repo. However that needs to be defined as a new remote
  63. , title : 'userfork-public'
  64. , accessibility : ['public'] /*public : true, external: true */
  65. }
  66. // PB : TODO -- Load private repositories from private config...
  67. , 'userfork-private' : { priority : 2,
  68. server : `http://git.bbh`, user : options.username || '', path : ``
  69. , get url(){ return `${this.server}/${options.username}/${this.path}`}
  70. , title : 'userfork-private'
  71. , accessibility : ['private']
  72. }
  73. , 'userfork-unc' : {
  74. priority : 3,
  75. server : `//172.16.0.27/repos`, user : `${options.username}`, path : ``
  76. , get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
  77. , title : 'userfork-unc'
  78. , accessibility : ['unc']
  79. // , unc : true, private : true
  80. }
  81. }
  82. )
  83. }
  84. // , { `${options.username}` : `https://git.bbh.org.in/${options.username}/elxr.git` }
  85. // PB : TODO --
  86. // , 'fetch-remotes' : [] // Multiple fetch remotes are not supported by git.
  87. // We therefore need to use
  88. // - a pullall
  89. // - or branch alias for multiple remote branch tracking branch strategy.
  90. // -- This is however limited to corresponding branch names
  91. // tracking branches.
  92. // We at least need one branch for each remote that we wish to track.
  93. // , 'tracking-branches' : [
  94. // { master : ['origin/master', 'chess/master'] }
  95. // ]
  96. // This is a list of all known repositories.
  97. var reposerverinstances = {
  98. // 'http://git.bbh' : { users, remotes }
  99. // , 'https://git.bbh.org.in' : { users, remotes, external : true }
  100. // , '//172.16.0.27/repos' : { users, remotes }
  101. // , 'https://github.com' : {
  102. // // We host a miniaml set of repositories in github.
  103. // get users() { return [{ username : `${this.username}` }]}, username : `baptistdev`
  104. // , remotes : {
  105. // 'baptistdev-public' : {
  106. // server : `https://github.com`, user : 'bAptistdev', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
  107. // , push : 'no-pushing' }
  108. // // , Add other remotes here.
  109. // }
  110. // , external : true, public : true
  111. // }
  112. }
  113. Object.keys(remotes).forEach(
  114. (k) => {
  115. var v = remotes[k]
  116. // var reposerverinstances = {}
  117. reposerverinstances[v.server] = reposerverinstances[v.server] || { users : [], remotes : {} };
  118. utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }
  119. , reposerverinstances[v.server].users, v.users || [v.user] )
  120. // if(v.server === options.reposerver) v.upstream = true;
  121. reposerverinstances[v.server].remotes[k] = v; // Assign ??
  122. }
  123. )
  124. return {
  125. // We need currently active ( as preferred by client ) repositories and remotes...
  126. //
  127. reposervers : Object.keys(reposerverinstances)
  128. , reposerverinstances
  129. , remotes
  130. , get reposindexed(){
  131. // PB : TODO -- Implement -- One time gettor and then cached...
  132. var indexed = {}
  133. this.repos.forEach(r => { indexed[r.repo] = r })
  134. return indexed;
  135. }
  136. , repos : [
  137. { repo : 'elxr' }
  138. ]
  139. }
  140. })