選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

repo-manifest.js 7.2KB

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