* Create a new branch from an existing branch. * @param {string} [oldBranch=master] - the name of the existing branch * @param {string} newBranch - the name of the new branch * @param {Requestable.callback} cb - will receive the commit data for the head of the new branch * @return {P
(oldBranch, newBranch, cb)
| 565 | * @return {Promise} - the promise for the http request |
| 566 | */ |
| 567 | createBranch(oldBranch, newBranch, cb) { |
| 568 | if (typeof newBranch === 'function') { |
| 569 | cb = newBranch; |
| 570 | newBranch = oldBranch; |
| 571 | oldBranch = 'master'; |
| 572 | } |
| 573 | |
| 574 | return this.getRef(`heads/${oldBranch}`) |
| 575 | .then((response) => { |
| 576 | let sha = response.data.object.sha; |
| 577 | return this.createRef({ |
| 578 | sha, |
| 579 | ref: `refs/heads/${newBranch}`, |
| 580 | }, cb); |
| 581 | }); |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Create a new pull request |
no test coverage detected