Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

repo-manifest.js 7.2KB

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