Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@ Clone.clone = function(url, local_path, options) {
normalizeOptions(remoteCallbacks, NodeGit.RemoteCallbacks);
}

return clone.call(this, url, local_path, options);
// This is required to clean up after the clone to avoid file locking
// issues in Windows and potentially other issues we don't know about.
var freeRepository = function(repository) {
repository.free();
};

// We want to provide a valid repository object, so reopen the repository
// after clone and cleanup.
var openRepository = function() {
return NodeGit.Repository.open(local_path);
};

return clone.call(this, url, local_path, options)
.then(freeRepository)
.then(openRepository);
};

module.exports = Clone;
8 changes: 0 additions & 8 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ beforeEach(function() {
});

afterEach(function(done) {
// In Windows if you do not clean up the repository, there may become a
// conflict with file locking.
if (this.repository && process.platform === "win32") {
this.repository.stateCleanup();
this.repository.free();
delete this.repository;
}

process.nextTick(function() {
global.gc();
done();
Expand Down
15 changes: 0 additions & 15 deletions test/tests/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@ describe("Clone", function() {
// Set a reasonable timeout here now that our repository has grown.
this.timeout(30000);

beforeEach(function(done) {
// In Windows if you do not clean up the repository, there may become a
// conflict with file locking.
if (this.repository && process.platform === "win32") {
this.repository.stateCleanup();
this.repository.free();
delete this.repository;
}

process.nextTick(function() {
global.gc();
done();
});
});

beforeEach(function() {
return fse.remove(clonePath).catch(function(err) {
console.log(err);
Expand Down