octonode
octonode copied to clipboard
createReference syntax and example is misleading
This should be an easy fix and I think it could be helpful for user looking to create a new branch.
createReference is passed three arguments: ghrepo.createReference('master', '18293abcd72', callback);
The first argument should be the new branch name. The second argument should be the SHA-1 hash value of the commit to branch off.
A better example would be as follows:
// get the latest commit
ghrepo.commits((err, status, body, headers) => {
if (err) { console.log('err', err) }
if (status) {
// for some reason status is an array of object that contains our commits.
// status[0] is the latest commit and we pass it to createReference
ghrepo.createReference('newBranchName', status[0].sha, (err, status, body, headers) => {
// do your stuff here
});
}
});
I was also inspecting the definition of createReference on line 340 for repo.js
and it looks correct! In my personal opinion, the example within the documentation is slightly misleading. I had to dive into the definition and source other examples to get a better understanding.
If you approve, I could create a PR for this.
Sure, go ahead.