MCPcopy Index your code
hub / github.com/github-tools/github / createBranch

Method createBranch

lib/Repository.js:567–582  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 1

repository.spec.jsFile · 0.80

Calls 2

getRefMethod · 0.95
createRefMethod · 0.95

Tested by

no test coverage detected