-
Notifications
You must be signed in to change notification settings - Fork 698
Closed
Description
I'm using NodeGit to setup multiple git repositories.
When I do that I get the error:
[1] 7896 segmentation fault (core dumped) node example.js
This error happens with NodeGit 0.5.0 and 0.6.0.
Running on Ubuntu 15.10, on Node JS 5.2.0 and 4.3.2
Here is the code I am trying to run.
This will work correctly with a single destination, but will SegFault with multiple.
A version of this code previously worked with multiple destinations with NodeGit 0.4.0
'use strict';
const NodeGit = require('nodegit');
const path = require('path');
const temporaryFolder = path.join(__dirname, 'temp');
const branchReference = 'refs/heads/master:refs/heads/master';
// replace this with your own username and password
// seedRepository should have files already
// destinationRepositories should not have any files or commits yet
seedRepositories('testUser', 'password', 'https://github.com/ChristianMurphy/just-a-test-ignore-this', ['https://github.com/ChristianMurphy/please-work-1', 'https://github.com/ChristianMurphy/please-work-2'])
function seedRepositories (username, password, seedRepositoryURL, destinationRepositoryURLs) {
const credentials = NodeGit.Cred.userpassPlaintextNew(username, password);
// clone seed repo
NodeGit.Clone(seedRepositoryURL, temporaryFolder, {
callbacks: {
credentials: function () {
return credentials;
}
}
})
// open the repository
.then(() => {
return NodeGit.Repository.open(temporaryFolder);
})
// push the seed repository to all destination repositories
.then((seedRepository) => {
const promises = [];
// for each destination
for (let index = 0; index < destinationRepositoryURLs.length; index++) {
// create a remote for destination
NodeGit.Remote.create(seedRepository, index.toString(), destinationRepositoryURLs[index]);
// open remote for destination and collect resulting promise
promises.push(
NodeGit.Remote.lookup(seedRepository, index.toString())
.then((remote) => {
// push to destination remote
return remote.push([branchReference], {
callbacks: {
credentials: function () {
return credentials;
}
}
});
})
);
}
// wait for all pushes to complete
return Promise.all(promises);
})
.catch((err) => {
console.error(err);
});
};Metadata
Metadata
Assignees
Labels
No labels