2016-03-30 23:59:45 +00:00
|
|
|
"use strict";
|
2016-06-12 14:46:59 +00:00
|
|
|
require("typings-global");
|
2016-03-30 23:59:45 +00:00
|
|
|
var plugins = require("./smartgit.plugins");
|
|
|
|
var SmartgitCheck = require("./smartgit.check");
|
2016-06-12 14:46:59 +00:00
|
|
|
exports.clone = function (options) {
|
2016-03-30 23:59:45 +00:00
|
|
|
var done = plugins.Q.defer();
|
|
|
|
/***** URL Checks ******/
|
2016-06-12 14:46:59 +00:00
|
|
|
//TODO make smartstring URL test
|
2016-03-30 23:59:45 +00:00
|
|
|
/***** Path Checks ******/
|
|
|
|
if (!/^\/.*/.test(options.to)) {
|
|
|
|
plugins.beautylog.error("It seems that the given path " + options.to + " is not absolute.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
plugins.beautylog.log("Now cloning " + options.from);
|
2016-06-12 14:46:59 +00:00
|
|
|
var cloneOptions = {
|
|
|
|
fetchOpts: {
|
|
|
|
callbacks: {
|
|
|
|
certificateCheck: function () { return 1; },
|
|
|
|
credentials: function (url, userName) {
|
|
|
|
return plugins.nodegit.Cred.sshKeyFromAgent(userName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var cloneRepository = plugins.nodegit.Clone.clone(options.from, options.to, cloneOptions)
|
|
|
|
.then(function () {
|
|
|
|
SmartgitCheck(cloneRepository);
|
|
|
|
done.resolve();
|
|
|
|
});
|
2016-03-30 23:59:45 +00:00
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
|
2016-06-12 14:46:59 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Z2l0LmNsb25lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBTyxPQUFPLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUMvQ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gPSB7XG4gICAgICAgIGZldGNoT3B0czoge1xuICAgICAgICAgICAgY2FsbGJhY2tzOiB7XG4gICAgICAgICAgICAgICAgY2VydGlmaWNhdGVDaGVjazogZnVuY3Rpb24oKSB7IHJldHVybiAxOyB9LFxuICAgICAgICAgICAgICAgIGNyZWRlbnRpYWxzOiBmdW5jdGlvbih1cmwsIHVzZXJOYW1lKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBwbHVnaW5zLm5vZGVnaXQuQ3JlZC5zc2hLZXlGcm9tQWdlbnQodXNlck5hbWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgdmFyIGNsb25lUmVwb3NpdG9yeSA9IHBsdWdpbnMubm9kZWdpdC5DbG9uZS5jbG9uZShvcHRpb25zLmZyb20sIG9wdGlvbnMudG8sIGNsb25lT3B0aW9ucylcbiAgICAgICAgLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgU21hcnRnaXRDaGVjayhjbG9uZVJlcG9zaXRvcnkpO1xuICAgICAgICAgICAgZG9uZS5yZXNvbHZlKCk7XG4gICAgICAgIH0pO1xuICAgIHJldHVybiBkb25lLnByb21pc2U7XG59OyJdfQ==
|