Skip to content

How to create Branch using the API? #124

Closed

Description

@mainlove

I can not find it

Activity

  1. demian85 commented on Apr 2, 2014

    @demian85

    up! (?)

  2. tbranyen commented on Apr 2, 2014

    @tbranyen
    Member
  3. sameoldmadness commented on Apr 5, 2014

    @sameoldmadness

    Should require("nodegit").Branch be undefined?

    I'm a bit confused about not finding any mention of branches in nodegit's js codebase.

  4. tbranyen commented on Apr 5, 2014

    @tbranyen
    Member

    @sameoldmadness Interesting, looks like it is stripped from the binding.gyp file. We should try and get that included, thanks for catching it.

  5. leileichrist commented on Jun 29, 2016

    @leileichrist

    I'm trying to create a branch using the Repository#createBranch method but it throws an empty error "{}". Could you guys take a look at what I'm doing wrong ?

    exports.createBranch = function (req, res) {
        var branchName = req.body["branch_name"];
        var name = req.body["name"];
        var email = req.body["email"];
        var message =  "branch {0} created".format(branchName);
        NodeGit.Repository.open(config.database).then(function (repo) {
            return repo.getHeadCommit();
        }).then(function (commit) {
            var signature = NodeGit.Signature.now(name, email);
            return repo.createBranch(branchName, commit, 0, signature, message);
        }).then(function (branch) {
            console.log(branch);
            res.status(200).json({message: "OK", data: branch.toString()});
        }).catch(function (err) {
            res.status(500).json({message: err, data: []});
        }).done(function () {
            console.log("finished");
        });
    };
    

    The line res.status(500).json({message: err, data: []}); gets called with an empty err object "{}".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions