work in progress

This commit is contained in:
Philipp Kunz
2015-11-13 22:58:20 +01:00
parent a5d7a9b550
commit a2d9a3a3e5
9 changed files with 118 additions and 38 deletions

View File

@ -1,36 +1,25 @@
/// <reference path="typings/tsd.d.ts" />
var path = require("path");
var beautylog = require("beautylog")("os");
var nodegit = require("nodegit");
/// <reference path="smartgit.clone.ts" />
/// <reference path="smartgit.init.ts" />
/// <reference path="smartgit.commit.ts" />
var plugins = {
path: require("path"),
beautylog: require("beautylog")("os"),
nodegit: require("nodegit"),
Q: require("q")
};
var smartgit:any = {};
smartgit.clone = function(cloneURL:string = "undefined" ,dest:string = "undefined"){
if (cloneURL == "undefined" || dest == "undefined") {
beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
return;
smartgit.clone = SmartgitClone
smartgit.commit = function(pathArg:string,commitMessage:string) {
var result = plugins.nodegit.index.addByPath(pathArg);
if (result == 0) {
}
var cloneOptions:any = {};
cloneOptions.remoteCallbacks = {
certificateCheck: function() { return 1; },
credentials: function(url, userName) {
return nodegit.Cred.sshKeyFromAgent(userName);
}
};
var cloneRepository = nodegit.Clone(cloneURL, dest, cloneOptions);
var errorAndAttemptOpen = function() {
return nodegit.Repository.open(dest);
};
cloneRepository.catch(errorAndAttemptOpen)
.then(function(repository) {
// Access any repository methods here.
console.log("Is the repository bare? %s", Boolean(repository.isBare()));
});
};
smartgit.commit = function(commitMessage:string) {
};
smartgit.init = function(dest:string = "undefined") {
@ -38,9 +27,14 @@ smartgit.init = function(dest:string = "undefined") {
return; // ...and return function here if not
}
var isBare = 0; //lets create a subfolder
nodegit.Repository.init(dest, isBare).then(function (repo) {
plugins.nodegit.Repository.init(dest, isBare).then(function (repo) {
// do something with repo here.
});
};
smartgit.check = function(repository) {
return true;
};
module.exports = smartgit;

0
ts/smartgit.add.ts Normal file
View File

34
ts/smartgit.clone.ts Normal file
View File

@ -0,0 +1,34 @@
/// <reference path="./index.ts" />
module SmartgitClone {
export function init() {
var clone = function(cloneURL:string = "undefined" ,dest:string = "undefined"){
/***** URL Checks ******/
if (cloneURL == "undefined" || dest == "undefined") {
plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
return;
}
/***** Path Checks ******/
if (!/^\/.*/.test(dest)){ //check wether path is absolute
plugins.beautylog.error("It seems that the given path " + dest + " is not absolute.");
return;
}
plugins.beautylog.log("Now cloning " + cloneURL);
var cloneOptions:any = {};
cloneOptions.remoteCallbacks = {
certificateCheck: function() { return 1; },
credentials: function(url, userName) {
return plugins.nodegit.Cred.sshKeyFromAgent(userName);
}
};
var cloneRepository = plugins.nodegit.Clone(cloneURL, dest, cloneOptions);
smartgit.check(cloneRepository);
};
return clone;
}
}

0
ts/smartgit.init.ts Normal file
View File

View File

@ -1,3 +1,10 @@
/// <reference path="typings/tsd.d.ts" />
var smartgit = require("./index.js");
var beautylog = require("beautylog");
var beautylog = require("beautylog")("os");
var path = require("path");
smartgit.clone("https://github.com/pushrocks/cooltest.git",path.resolve("./test/"));
beautylog.success("Test successfull");