Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

createReference syntax and example is misleading #334

Open
richsong opened this issue Nov 4, 2019 · 1 comment
Open

createReference syntax and example is misleading #334

richsong opened this issue Nov 4, 2019 · 1 comment

Comments

@richsong
Copy link

richsong commented Nov 4, 2019

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.

@pksunkara
Copy link
Owner

Sure, go ahead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants