diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 71e50af..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-language: node_js
-node_js:
-- 4
-- stable
-before_install:
-- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
-- sudo apt-get update
-- sudo apt-get install libstdc++-4.9-dev -y
-deploy:
- provider: npm
- email: npm@lossless.digital
- api_key:
- secure: o/3H4keWRAvHZaJnUN9UX+hqu+prKGtBsOEWVIaRXUpf6nIHIDm9zlJrS5cv2VUseOZqLAOkzeGYPqlOJlxccy5frKEYMhtCY97BjKvUOf01roL82OGiahw5Bv04NcaBoSepCliyyXihlgZO/5tSoR1seY4ycul2qWLktaEmh8HcTPjem8gB49Svpfk8yPKLpq6cv/sSakt2X24Cq+vfdxYiz7GcgBfv3EVAndUmQ9KMQfkSbq8XgYEZKrLi5kdpXX0y1LRdsbn2rwuMwLOmefCenmQSuBCbYmbOxPgVHHHjVm9To/rhx8YHBCcZSH9go2pdDLwrd7VPOCK+vMHCz/rlASwVM/BGr+aJHCFLAyovrIU7cvbbjLPOUjto6xY2XckMmDBD1YDxYnAJAON1QrdXE9hVVRfMNfaC2leFAwhla1WMok5DcEv+/Q9cUXQCBGQHtBhkhmCCt54ERLFnjXCDZr1icR/0lhtQY54hin5jSHqnU2hTZtTpQX7sF0yZM2sbhTBpV5FTDAGH/ohNWSEnTwAXmL9iwZCTvtWUbBeOUSDRj8BLS54uiaIcIVytNY0p2PdnhwJAWO+4FGjSOT+RuK8RiKzyVXjPiX8TCzaOqBFs947m8SSNMSt6zyqOI27gOSzU7szgsKY769Fl+X9sdzFXaSa72rj4EdvgiBA=
- on:
- tags: true
- repo: pushrocks/smartgit
-notifications:
- slack:
- secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
diff --git a/LICENSE b/LICENSE
index b8e36c1..cff2fa1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2015 Push.Rocks
+Copyright (c) 2015 Lossless GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/index.js b/index.js
deleted file mode 100644
index f937cb0..0000000
--- a/index.js
+++ /dev/null
@@ -1,90 +0,0 @@
-///
-var SmartgitPlugins;
-(function (SmartgitPlugins) {
- SmartgitPlugins.init = function () {
- var plugins = {
- path: require("path"),
- beautylog: require("beautylog"),
- nodegit: require("nodegit"),
- Q: require("q")
- };
- return plugins;
- };
-})(SmartgitPlugins || (SmartgitPlugins = {}));
-///
-var SmartgitClone;
-(function (SmartgitClone) {
- function init() {
- var clone = function (options) {
- /***** URL Checks ******/
- if (options.from == "undefined" || options.to == "undefined") {
- plugins.beautylog.error("smartgit.clone".blue + " : Something is strange about the way you invoked the function");
- return;
- }
- /***** 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);
- var cloneOptions = {};
- var cloneRepository = plugins.nodegit.Clone(options.from, options.to, cloneOptions);
- smartgit.check(cloneRepository);
- };
- return clone;
- }
- SmartgitClone.init = init;
-})(SmartgitClone || (SmartgitClone = {}));
-///
-var SmartgitInit;
-(function (SmartgitInit) {
- SmartgitInit.init = function () {
- var gitinit = function (dest) {
- if (dest === void 0) { dest = "undefined"; }
- if (dest == "undefined") {
- 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.
- });
- };
- return gitinit;
- };
-})(SmartgitInit || (SmartgitInit = {}));
-///
-var SmartgitCommit;
-(function (SmartgitCommit) {
- SmartgitCommit.init = function () {
- var commit = function (pathArg, commitMessage) {
- var result = plugins.nodegit.index.addByPath(pathArg);
- if (result == 0) {
- }
- };
- return commit;
- };
-})(SmartgitCommit || (SmartgitCommit = {}));
-///
-var SmartgitCheck;
-(function (SmartgitCheck) {
- SmartgitCheck.init = function () {
- var check = function () {
- return true;
- };
- return check;
- };
-})(SmartgitCheck || (SmartgitCheck = {}));
-///
-///
-///
-///
-///
-///
-var plugins = SmartgitPlugins.init();
-//Build the smartgit object
-var smartgit = {};
-smartgit.clone = SmartgitClone.init();
-smartgit.commit = SmartgitCommit.init();
-smartgit.check = SmartgitCheck.init();
-smartgit.init = SmartgitInit.init();
-module.exports = smartgit;
diff --git a/test.js b/test.js
deleted file mode 100644
index 2129f5a..0000000
--- a/test.js
+++ /dev/null
@@ -1,9 +0,0 @@
-///
-var smartgit = require("./index.js");
-var beautylog = require("beautylog");
-var path = require("path");
-smartgit.clone({
- from: "https://github.com/pushrocks/docs.git",
- to: path.resolve("./test/temp/")
-});
-beautylog.success("Test successfull");
diff --git a/ts/index.ts b/ts/index.ts
index df8470f..e1486ae 100644
--- a/ts/index.ts
+++ b/ts/index.ts
@@ -1,28 +1,3 @@
import plugins = require('./smartgit.plugins');
-import { GitRepo } from './smartgit.classes.gitrepo';
-export { GitRepo };
-
-/**
- * creates a new GitRepo Instance after cloning a project
- */
-export const createRepoFromClone = async (fromArg: string, toArg: string): Promise => {
- let done = q.defer();
- plugins.smartfile.fs.ensureDir(toArg);
- plugins.shelljs.exec(`git clone ${fromArg} ${toArg}`);
- let newRepo = new GitRepo(toArg);
- done.resolve(newRepo);
- return done.promise;
-};
-
-/**
- * creates a new GitRepo instance after initializing a new Git Repository
- */
-export const createRepoFromInit = async (destinationDirArg: string): Promise => {
- const done = q.defer();
- plugins.smartfile.fs.ensureDir(destinationDirArg);
- plugins.shelljs.exec(`cd ${destinationDirArg} && git init`);
- let newRepo = new GitRepo(destinationDirArg);
- done.resolve(newRepo);
- return done.promise;
-};
+export * from './smartgit.classes.gitrepo';
diff --git a/ts/smartgit.classes.gitrepo.ts b/ts/smartgit.classes.gitrepo.ts
index a090680..b52dc9d 100644
--- a/ts/smartgit.classes.gitrepo.ts
+++ b/ts/smartgit.classes.gitrepo.ts
@@ -9,16 +9,51 @@ export class GitRepo {
* creates a new GitRepo Instance after cloning a project
*/
public static async createRepoFromClone(fromArg: string, toArg: string): Promise {
- return new GitRepo();
+ const dirArg = plugins.path.resolve(toArg);
+ const ngRespository = await plugins.nodegit.Clone.clone(fromArg, toArg, {
+ bare: 0,
+ checkoutBranch: 'master'
+ });
+ return new GitRepo(ngRespository);
}
- /**
- * creates a new GitRepo instance after initializing a new Git Repository
- */
- public static async createRepoFromInit(destinationDirArg: string): Promise {
- return new GitRepo();
+ public static async createNewRepoInDir(dirArg: string): Promise {
+ dirArg = plugins.path.resolve(dirArg);
+ const ngRepository = await plugins.nodegit.Repository.init(dirArg, 0);
+ return new GitRepo(ngRepository);
+ }
+
+ public static async openRepoAt(dirArg: string) {
+ dirArg = plugins.path.resolve(dirArg);
+ const ngRepository = await plugins.nodegit.Repository.open(dirArg);
+ return new GitRepo(ngRepository);
}
// INSTANCE
- nodegitRepo;
+ public nodegitRepo: plugins.nodegit.Repository;
+
+ constructor(nodegitRepoArg: plugins.nodegit.Repository) {
+ this.nodegitRepo = nodegitRepoArg;
+ }
+
+ /**
+ * lists remotes
+ */
+ public async listRemotes(): Promise {
+ return this.nodegitRepo.getRemotes();
+ }
+
+ /**
+ * gets the url for a specific remote
+ */
+ public async getUrlForRemote(remoteName: string) {
+ const ngRemote = await this.nodegitRepo.getRemote(remoteName);
+ return ngRemote.url;
+ }
+
+ public async pushBranchToRemote(branchName: string, remoteName: string) {
+ await this.nodegitRepo.checkoutBranch(branchName);
+ const ngRemote = await this.nodegitRepo.getRemote(remoteName);
+ ngRemote.push([branchName]);
+ }
}