Skip to content

Commit

Permalink
Creates repo.branch function, closes github-tools#36
Browse files Browse the repository at this point in the history
Commit with tweaks from @itsjoesullivan, see pull github-tools#37
Combined if statement, got rid of whitespace and made note of default to
master in README.md
  • Loading branch information
mattpass committed Oct 2, 2013
1 parent 8b43038 commit a5ae9bd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Fork repository. This operation runs asynchronously. You may want to poll for `r
repo.fork(function(err) {});
```

Create new branch for repo. You can omit oldBranchName to default to "master".

```js
repo.branch(oldBranchName, newBranchName, function(err) {});
```

Create Pull Request.

```js
Expand Down
18 changes: 18 additions & 0 deletions github.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,24 @@
_request("POST", repoPath + "/forks", null, cb);
};

// Branch repository
// --------

this.branch = function(oldBranch,newBranch,cb) {
if(arguments.length === 2 && typeof arguments[1] === "function") {
cb = newBranch;
newBranch = oldBranch;
oldBranch = "master";
}
this.getRef("heads/" + oldBranch, function(err,ref) {
if(err && cb) return cb(err);
that.createRef({
ref: "refs/heads/" + newBranch,
sha: ref
},cb);
});
}

// Create pull request
// --------

Expand Down

0 comments on commit a5ae9bd

Please sign in to comment.