nl_tokens: Create a new branch with the given name .
pl_tokens: function create ( repositoryState , driver , name , opts = { } ) { const { // Base branch for the new branch <mask> = repositoryState . getCurrentBranch ( ) , // Fetch the working state and switch to it ? checkout = true , // Drop changes from base branch the new working state ? clean = true , // Drop changes from the base branch ? cleanBase = false } = opts ; let createdBranch ; return driver . createBranch ( base , name ) // Update list of branches . then ( ( branch ) => { createdBranch = branch ; let branches = repositoryState . getBranches ( ) ; branches = branches . push ( createdBranch ) ; return repositoryState . set ( 'branches' , branches ) ; } ) // Update working state or fetch it if needed . then ( ( repoState ) => { let baseWk = repoState . getWorkingStateForBranch ( base ) ; if ( ! baseWk ) { return checkout ? RepoUtils . fetchTree ( repoState , driver , createdBranch ) : repoState ; } // Reuse base WorkingState clean const headWk = clean ? baseWk . asClean ( ) : baseWk ; repoState = RepoUtils . updateWorkingState ( repoState , createdBranch , headWk ) ; // Clean base WorkingState baseWk = cleanBase ? baseWk . asClean ( ) : baseWk ; repoState = RepoUtils . updateWorkingState ( repoState , base , baseWk ) ; return repoState ; } ) // Checkout the branch . then ( ( repoState ) => { if ( ! checkout ) { return repoState ; } return RepoUtils . checkout ( repoState , createdBranch ) ; } ) ; }