|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- module.exports = ((name, options)=>{
-
- options = options || { username : ``, reposerver : `https://git.bbh.org.in` }
- utils = options.utils
-
- // Default set of users in main repos.
- var users = [
- { username : `${options.username}`, password : `${options.password}` }
- , { username : `guest`}
- // , { username : `baptistdev`, password : 'encrypted' }
- // , { username : `guest`, password : 'encrypted' }
- ]
-
- // ${options.reposerver} should be used to lookup current config.
-
- // User can always add more branches and remotes as needed. Mainifest defines and occupies
- // a dictionary of well defined remote names
- var remotes = { // these are both fetch and push remotes. Use push - remotes to override push.
- 'chess' : {
- priority : 0,
- // PB : TODO -- Handle cases where a repository url can be accessed by multiple users...
- server : `${options.reposerver}`, user : options.username || '', path : ``
- , get url(){ return `${this.server}/chess/${this.path}`} // fetch
- , push : 'no-pushing'
- , title : 'chess'
- }
- , 'chess-public' : { priority : 1,
- server : `https://git.bbh.org.in`, user : options.username || '', path : ``
- , get url(){ return `${this.server}/chess/${this.path}`}
- , title : 'chess-public' // PB : TODO -- rename...
- , accessibility : ['public']
- , push : 'no-pushing'
- }
- // PB : TODO -- Load private repositories from private config...
- , 'chess-private' : { priority : 2,
- server : `http://git.bbh`, user : options.username || '', path : ``
- , get url(){ return `${this.server}/chess/${this.path}`}
- , title : 'chess-private'
- , accessibility : ['private']
- , push : 'no-pushing', private : true
- }
- , 'chess-github' : { priority : 3,
- server : `https://github.com`, user : 'baptistdev', path : ``
- , get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
- , title : 'chess-github'
- , accessibility : ['public']
- , push : 'no-pushing' //, external : true, public : true
- }
- }
-
- // Multiple urls dont tell us the current origin which may be
- // different based on currently available/accessible based on device and client.
- // We just treat them as different remotes and merge as needed.
-
-
- if(options.username) {
- utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }
- , remotes
- , { 'userfork' : {
- priority : 1,
- server : `${options.reposerver}`, user : `${options.username}`, path : ``
- , get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
- , title : 'userfork'
- }
- , 'userfork-public' : {
- priority : 1,
- server : `https://git.bbh.org.in`, user : `${options.username}`, path : ``
- , get url(){ return `${this.server}/${this.user}/${this.path}`}
- // PB : TODO - Other users may have access to this users repo. However that needs to be defined as a new remote
- , title : 'userfork-public'
- , accessibility : ['public'] /*public : true, external: true */
- }
- // PB : TODO -- Load private repositories from private config...
- , 'userfork-private' : { priority : 2,
- server : `http://git.bbh`, user : options.username || '', path : ``
- , get url(){ return `${this.server}/${options.username}/${this.path}`}
- , title : 'userfork-private'
- , accessibility : ['private']
- }
- , 'userfork-unc' : {
- priority : 3,
- server : `//172.16.0.27/repos`, user : `${options.username}`, path : ``
- , get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
- , title : 'userfork-unc'
- , accessibility : ['unc']
- // , unc : true, private : true
- }
- }
- )
- }
- // , { `${options.username}` : `https://git.bbh.org.in/${options.username}/elxr.git` }
-
-
- // PB : TODO --
- // , 'fetch-remotes' : [] // Multiple fetch remotes are not supported by git.
- // We therefore need to use
- // - a pullall
- // - or branch alias for multiple remote branch tracking branch strategy.
- // -- This is however limited to corresponding branch names
-
- // tracking branches.
- // We at least need one branch for each remote that we wish to track.
- // , 'tracking-branches' : [
- // { master : ['origin/master', 'chess/master'] }
- // ]
-
- // This is a list of all known repositories.
- var reposerverinstances = {
- // 'http://git.bbh' : { users, remotes }
- // , 'https://git.bbh.org.in' : { users, remotes, external : true }
- // , '//172.16.0.27/repos' : { users, remotes }
- // , 'https://github.com' : {
- // // We host a miniaml set of repositories in github.
- // get users() { return [{ username : `${this.username}` }]}, username : `baptistdev`
- // , remotes : {
- // 'baptistdev-public' : {
- // server : `https://github.com`, user : 'bAptistdev', path : ``, get url(){ return `${this.server}/${this.user}/${this.path}`} // fetch
- // , push : 'no-pushing' }
- // // , Add other remotes here.
- // }
- // , external : true, public : true
- // }
- }
-
- Object.keys(remotes).forEach(
- (k) => {
- var v = remotes[k]
-
- // var reposerverinstances = {}
- reposerverinstances[v.server] = reposerverinstances[v.server] || { users : [], remotes : {} };
- utils.assign_core( { arraymergetype : utils.assign_core.DISTINCT_UNION }
- , reposerverinstances[v.server].users, v.users || [v.user] )
-
- // if(v.server === options.reposerver) v.upstream = true;
- reposerverinstances[v.server].remotes[k] = v; // Assign ??
- }
- )
-
- return {
- // We need currently active ( as preferred by client ) repositories and remotes...
- //
- reposervers : Object.keys(reposerverinstances)
- , reposerverinstances
- , remotes
- , get reposindexed(){
- // PB : TODO -- Implement -- One time gettor and then cached...
- var indexed = {}
- this.repos.forEach(r => { indexed[r.repo] = r })
- return indexed;
- }
- , repos : [
- { repo : 'elxr' }
- ]
- }
- })
|