now using native git through shelljs since it proves to be much more stable

This commit is contained in:
2016-07-02 02:22:03 +02:00
parent 527d1b7aa5
commit c8c9d8a407
24 changed files with 56 additions and 132 deletions

2
ts/postinstall.ts Normal file
View File

@@ -0,0 +1,2 @@
import shelljs = require("shelljs");
import beautylog = require("beautylog");

View File

@@ -2,6 +2,5 @@ import "typings-global";
import * as plugins from "./smartgit.plugins";
export let pull = (optionsArg:{path:string,ref?:string}) => {
if(!optionsArg.ref) optionsArg.ref = "master";
plugins.nodegit.Repository.open(optionsArg.path);
}

View File

@@ -2,45 +2,16 @@ import "typings-global"
import plugins = require("./smartgit.plugins");
import SmartgitCheck = require("./smartgit.check");
export let clone = (optionsArg:{
from:string,
to:string,
keyPath?:string,
keyPassphrase?:string
}) => {
export let clone = (optionsArg: {
from: string,
to: string,
key?: string,
keyPath?: string,
keyPassphrase?: string
}) => {
let done = plugins.Q.defer();
/***** URL Checks ******/
//TODO make smartstring URL test
/***** Path Checks ******/
if (!/^\/.*/.test(optionsArg.to)){ //check wether path is absolute
plugins.beautylog.error("It seems that the given path " + optionsArg.to + " is not absolute.");
return;
}
plugins.beautylog.log("Now cloning " + optionsArg.from);
var cloneOptions:any = {
fetchOpts: {
callbacks: {
certificateCheck: function() { return 1; },
credentials: function(url, userName) {
let gitRepo = new plugins.smartstring.GitRepo(url);
let host = gitRepo.host;
let sshDir = plugins.path.join(plugins.smartpath.get.home(),".ssh/")
let pubKeyPath = plugins.path.join(sshDir,host + ".pub");
let privKeyPath:string = plugins.path.join(sshDir,host);
if(!optionsArg.keyPassphrase) optionsArg.keyPassphrase = "";
return plugins.nodegit.Cred.sshKeyNew(userName, pubKeyPath, privKeyPath,optionsArg.keyPassphrase);
}
}
}
};
var cloneRepository = plugins.nodegit.Clone.clone(optionsArg.from, optionsArg.to, cloneOptions)
.then(() => {
SmartgitCheck(cloneRepository);
done.resolve();
},(err) => {
console.log(err);
});
plugins.smartfile.fs.ensureDir(optionsArg.to);
plugins.shelljs.exec(`cd ${optionsArg.to} && git clone ${optionsArg.from} .`);
done.resolve();
return done.promise;
};
};

View File

@@ -2,8 +2,7 @@ import "typings-global"
import plugins = require("./smartgit.plugins");
export = function(pathArg:string,commitMessage:string) {
var result = plugins.nodegit.index.addByPath(pathArg);
if (result == 0) {
}
let done = plugins.Q.defer();
done.resolve();
return done.promise;
};

View File

@@ -6,9 +6,7 @@ export = function(){
if (dest == "undefined") { //lets check if a destination is defined...
return; // ...and return function here if not
}
var isBare = 0; //lets create a subfolder
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
// do something with repo here.
});
};
}

View File

@@ -2,10 +2,8 @@ import "typings-global"
export import path = require("path");
export import beautylog = require("beautylog");
export let nodegit = require("nodegit");
export let Q = require("q");
export let shelljs = require("shelljs");
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");
export import smartstring = require("smartstring");