Switch from git-node to nodegit (temporary)

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 11 years ago
parent ff0f0e7a31
commit 9e2fa91600
  1. 63
      BuildServer/lib/git-loader.js
  2. 2
      BuildServer/package.json

@ -1,6 +1,6 @@
"use strict"; "use strict";
var git = require('git-node'), var nodegit = require('nodegit'),
async = require('async'), async = require('async'),
fs = require('fs'), fs = require('fs'),
fse = require('fs-extra'), fse = require('fs-extra'),
@ -26,70 +26,71 @@ options = {
module.exports = function (options, globalCallback) { module.exports = function (options, globalCallback) {
var url = options.remote, var url = options.remote,
remote = git.remote(url),
path = options.local + "/" + options.hash, path = options.local + "/" + options.hash,
repo = git.repo(path),
exported = options.exported, exported = options.exported,
opts = {
want: options.branch/*,
onProgress: function (progress) {
process.stderr.write(progress);
}*/
},
done = function () { done = function () {
globalCallback(); globalCallback();
}; };
removedirs(path);
mkdirs(path); mkdirs(path);
//console.log("Cloning %s to %s", url, path); if (url.substr(0, 8) == "https://") {
url = "git://" + url.substr(8);
}
console.log("Cloning %s to %s", url, path);
repo.fetch(remote, opts, function (err) { nodegit.Repo.clone(url, path, null /*new nodegit.CloneOptions({"checkout_branch": options.branch})*/, function (err, repo) {
if (err) { if (err) {
return globalCallback(err); return globalCallback(err);
} }
//console.log("Done fetching");
removedirs(exported);
mkdirs(exported);
var q = async.queue(function (task, callback) { var q = async.queue(function (task, callback) {
//console.log("Going to write file " + task.path + " (" + task.buffer.length + " bytes)"); //console.log("Going to write file " + task.path + " (" + task.buffer.length + " bytes)");
fs.writeFile(exported + "/" + task.path, task.buffer, function (err, result) { task.entry.getBlob(function (err, blob) {
if (err) {
return callback(err);
}
fs.writeFile(exported + "/" + task.path, blob.content(), function (err, result) {
//console.log("Done writing file " + task.path); //console.log("Done writing file " + task.path);
callback(err, result); callback(err, result);
}); });
});
}, 10); }, 10);
repo.treeWalk(options.hash, function (err, tree) { repo.getCommit(options.hash, function (err, commit) {
if (err) { if (err) {
return globalCallback(err); return globalCallback(err);
} }
var onEntry = function (err, entry) { removedirs(exported);
mkdirs(exported);
commit.getTree(function (err, tree) {
if (err) { if (err) {
return globalCallback(err); return globalCallback(err);
} }
if (!entry) { tree.walk(false)
.on('entry', function (entry) {
if (entry.isTree()) {
mkdirs(exported + "/" + entry.path());
} else if (entry.isFile()) {
q.push({path: entry.path(), entry: entry });
}
})
.on('end', function () {
if (q.length() === 0) { if (q.length() === 0) {
process.nextTick(done); process.nextTick(done);
} else { } else {
q.drain = done; q.drain = done;
} }
return; return;
} })
//console.log(" %s %s (%s)", entry.hash, entry.path, entry.type); .start();
if (entry.type === "tree") { });
mkdirs(exported + "/" + entry.path);
} else if (entry.type === "blob") {
q.push({path: entry.path, buffer: entry.body });
}
return tree.read(onEntry);
};
tree.read(onEntry);
}); });
}); });
}; };

@ -10,7 +10,7 @@
"jade": "*", "jade": "*",
"async": "~0.2.9", "async": "~0.2.9",
"fs-extra": "~0.8.1", "fs-extra": "~0.8.1",
"git-node": "~0.1.1", "nodegit": "~0.1.4",
"github": "~0.2.0", "github": "~0.2.0",
"glob": "~3.2.7", "glob": "~3.2.7",
"nodemailer": "~0.6.0", "nodemailer": "~0.6.0",

Loading…
Cancel
Save