Skip to content

Cannot create a new branch #391

Closed
Closed

Description

@ashokfernandez

I am trying to create a new branch in my repo, however I am getting an error about a callback not existing. This is using version 0.2.7 from NPM

Git = require('nodegit');

scope = {}

Git.Repository.open("./")
    .then(function(repo) {
        scope.repo = repo;
        return repo.getMasterCommit();
    })
    .then(function(masterCommit) {
        scope.masterCommit = masterCommit;
        return Git.Branch.create(scope.repo, "new-branch", scope.masterCommit, true)
    })
    .then(function(branch) {
        console.log(branch.toString())
    })
    .catch(function(err) {
        console.log(err.toString())
    })

This results in the output

Error: Callback is required and must be a Function.

Activity

  1. tbranyen commented on Feb 9, 2015

    @tbranyen
    Member

    I think the create method takes six arguments, you've passed 4.
    On Feb 9, 2015 10:28 AM, "Ashok Fernandez" notifications@github.com wrote:

    I am trying to create a new branch in my repo, however I am getting an
    error about a callback not existing. This is using version 0.2.27 from NPM

    Git = require('nodegit');

    scope = {}

    Git.Repository.open("./")
    .then(function(repo) {
    scope.repo = repo;
    return repo.getMasterCommit();
    })
    .then(function(masterCommit) {
    scope.masterCommit = masterCommit;
    return Git.Branch.create(scope.repo, "new-branch", scope.masterCommit, true)
    })
    .then(function(branch) {
    console.log(branch.toString())
    })
    .catch(function(err) {
    console.log(err.toString())
    })

    This results in the output

    Error: Callback is required and must be a Function.

    —
    Reply to this email directly or view it on GitHub
    #391.

  2. ashokfernandez commented on Feb 9, 2015

    @ashokfernandez
    Author

    Ahh I see, I was following the examples from the test files. What should be used for the signature parameter? Also is the head commit reference that I'm using from the tests correct?

    On Mon, Feb 9, 2015 at 6:12 PM, Tim Branyen notifications@github.com
    wrote:

    I think the create method takes six arguments, you've passed 4.
    On Feb 9, 2015 10:28 AM, "Ashok Fernandez" notifications@github.com wrote:

    I am trying to create a new branch in my repo, however I am getting an
    error about a callback not existing. This is using version 0.2.27 from NPM

    Git = require('nodegit');

    scope = {}

    Git.Repository.open("./")
    .then(function(repo) {
    scope.repo = repo;
    return repo.getMasterCommit();
    })
    .then(function(masterCommit) {
    scope.masterCommit = masterCommit;
    return Git.Branch.create(scope.repo, "new-branch", scope.masterCommit, true)
    })
    .then(function(branch) {
    console.log(branch.toString())
    })
    .catch(function(err) {
    console.log(err.toString())
    })

    This results in the output

    Error: Callback is required and must be a Function.

    —
    Reply to this email directly or view it on GitHub
    #391.


    Reply to this email directly or view it on GitHub:
    #391 (comment)

  3. maxkorp commented on Feb 10, 2015

    @maxkorp
    Collaborator

    Provided you have a git user configured, you should just be able to use Signature.default, which should grab the git global user name and email. I think the commit ref is correct, but I'd have to test to make sure. Those 5 args should be sufficient for you, as the promise should handle the 6th. I'm going to close this, and add creating a branch as a desired example. If you need more help, hop on into the Gitter room 👍

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