Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create a new branch #391

Closed
ashokfernandez opened this issue Feb 9, 2015 · 3 comments
Closed

Cannot create a new branch #391

ashokfernandez opened this issue Feb 9, 2015 · 3 comments

Comments

@ashokfernandez
Copy link

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.
@tbranyen
Copy link
Member

tbranyen commented Feb 9, 2015

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.

@ashokfernandez
Copy link
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)

@maxkorp
Copy link
Collaborator

maxkorp commented Feb 10, 2015

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 👍

@maxkorp maxkorp closed this as completed Feb 10, 2015
@maxkorp maxkorp mentioned this issue Feb 10, 2015
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants