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 : ['external', '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', 'internal'] , 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 : ['external', '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', 'external'] /*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', 'interanl'] } , '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 : ['private', '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 , repos : [ { repo : 'elxr' } ] } })